2012-09-04 85 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

相關問題