我正在努力学习 EventKit 提醒的基础知识。我正在尝试在这里重新创建教程:http ://www.techotopia.com/index.php/Using_iOS_6_Event_Kit_to_Create_Date_and_Location_Based_Reminders
但是,当我尝试构建项目时,我在 IBAction 和 CreateReminder 的 .m 文件中都出现“缺少方法声明的上下文”的错误。我试图在这里寻求建议,但似乎仍然无法弄清楚我做错了什么。不得不说这些教程有什么用,如果它们总是遗漏一些阻止它构建的基本信息。如果有人可以提供帮助,我将不胜感激。
#import <UIKit/UIKit.h>
#import <EventKit/EventKit.h>
@interface ReminderAppFirstViewController : UIViewController
@property (strong, nonatomic) EKEventStore *eventStore;
@property (strong, nonatomic) IBOutlet UIDatePicker *myDatePicker;
@property (strong, nonatomic) IBOutlet UITextField *reminderText;
- (IBAction)setReminder:(id)sender;
- (void)createReminder;
@end
- (IBAction)setReminder:(id)sender {
if (_eventStore == nil)
{
_eventStore = [[EKEventStore alloc]init];
[_eventStore requestAccessToEntityType:EKEntityTypeReminder comnpletion: ^(BOOL granted, NSError *error) ] {
if (!granted)
NSLog(@"Access to store not granted");
}];
}
if (_eventStore != nil)
[self createReminder];
}
- (void)createReminder
{
EKReminder *reminder = [EKReminder
reminderWithEventStore:self.eventStore];
reminder.title = _reminderText.text;
reminder.calendar = [_eventStore defaultCalendarForNewReminders];
NSDate *date = [_myDatePicker date];
EKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:date];
[reminder addAlarm:alarm];
NSError *error = nil;
[_eventStore saveReminder:reminder commit:YES error:&error];
if (error)
NSLog(@"error = %@", error);
}