2012-09-04 86 views
0

我正在关注here上的一个教程,其中包含通知和所有事件管理。现在的问题是,我得到下面的代码在“eventstore”类型的对象上找不到属性“标题”

我.h文件中

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


@interface ViewController : UIViewController 

- (IBAction) NewEvent:(id)sender; 


@end 

我.m文件错误

#import "ViewController.h" 
#import <EventKit/EventKit.h> 

@interface ViewController() 

@end 

@implementation ViewController 

- (IBAction) NewEvent:(id)sender { 

    EKEventStore *eventDB = [[EKEventStore alloc] init]; 
    EKEventStore *myEvent = [EKEvent eventWithEventStore:eventDB]; 

    myEvent.title = @"New Event"; // <-- Errors are appearing hear as shown in the title. 


} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 

@end 

其他信息: 我已经加入框架的工作,但仍然得到错误,如代码中所示。代码名称为

属性“标题”是不是类型的“eventstore”

预先感谢您:)对象中找到

+0

我不认为你的代码与该错误消息相匹配(本身看起来并不真实)。你能(a)从Xcode直接拷贝粘贴错误信息*,而不是解释它,(b)仔细检查你是否设置了'myEvent.title'而不是'eventDB.title'? – Tim

+0

好的,我找到了我的错误解决方案。我写错了代码。我写了'EKEventStore * myEvent = [EKEvent eventWithEventStore:eventDB];'而不是写'EKEvent * myEvent = [EKEvent eventWithEventStore:eventDB];'所以我的错。您能否请您回答我给您的答复,以便我可以投票。 – user1529095

回答

0

你要双精度检查myEvent是否是正确的类型(EKEvent *而不是EKEventStore *),并且您确实试图将标题设置为myEvent而不是eventDB。您发布的错误表示您在活动商店中设置了title,而不仅仅是一个活动。

+0

谢谢你帮助:) – user1529095

相关问题