在Xcode 4.2 iPhone中使用日历

时间:2012-02-28 19:44:34

标签: xcode xcode4 ios5 xcode4.2

我现在一直在学习Xcode 4.2,但仍然无法理解如何创建日历,所以我真的希望你们能帮助我解决我的错误并告诉我下一步是什么代码是让这个工作我真的很感谢你的时间谢谢。

这是故事板

this is my tabbed application storyboard

.h这里没有错误

#import <UIKit/UIKit.h>
#import <EventKitUI/EventKitUI.h>

@interface FirstViewController : UIViewController <EKEventEditViewDelegate> {

}

-(IBAction) createEvent; 

@end

.m这是错误的地方

#import "FirstViewController.h"
#import <EventKitUI/EventKitUI.h>

@implementation FirstViewController

-(IBAction) createEvent {
    //Get the event store object
    EKEventStore *eventStore = [[EKEventEditViewController alloc] INIT];

    //Cretae the EditViewController 
    EKEventEditViewController* controller = [[EKEventEditViewController alloc] INIT];
    controller.eventStore = eventStore;

    controller.editViewDelegate = self;

    [self presentModalViewController:controler animated:YES];

    [controller release];
}

//delegate method for EKEventEditViewDelegate
-(void)eventEditViewController:(EKEventEditViewController *)controller
         didCompleteWithAction:(EKEventEditViewAction)action {
    [self dismissModalViewControllerAnimated:YES];
}

错误:

EKEventStore *eventStore = [[EKEventEditViewController alloc] INIT];
  

接收器类型'EKEventEditViewController'实例消息未声明带有选择器'init'的方法

EKEventEditViewController* controller = [[EKEventEditViewController alloc] INIT];
  

接收器类型'EKEventEditViewController'实例消息未声明带有选择器'init'的方法

[controller release];
  

'release'不可用:在自动参考计数模式2中不可用

这就是所有的错误,希望你们可以告诉我什么是错的我真的很感激它:)

1 个答案:

答案 0 :(得分:0)

  1. 这是init,而不是INIT

  2. 如果您使用ARC,则需要摆脱[controller release];

  3. 所以,改为:

    -(IBAction) createEvent {
        //Get the event store object
        EKEventStore *eventStore = [[EKEventStore alloc] init];
    
        //Cretae the EditViewController 
        EKEventEditViewController* controller = [[EKEventEditViewController alloc] init];
        controller.eventStore = eventStore;
    
        controller.editViewDelegate = self;
    
        [self presentModalViewController:controler animated:YES];
    }