我正在关注here的教程,其中包括带有通知的事件管理和所有内容。现在的问题是我在以下代码中遇到错误
我的.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”类型的对象上找不到属性“title”
提前谢谢你:)
答案 0 :(得分:0)
您需要仔细检查myEvent
是否为正确类型(EKEvent *
而不是EKEventStore *
)并且您实际上是在尝试设置{{1而不是myEvent
。您发布的错误表示您在事件存储中设置eventDB
,而不仅仅是事件。