4
我正在創建一個簡單的便箋應用程序,並且要實施提醒。用戶可以輸入筆記,點擊一個按鈕,然後使用該文本在提醒應用程序中設置提醒。這是可能的,如果是這樣,我該怎麼做?我看過Apple關於EventKit和EKReminders的文檔,但它一直沒有幫助。以編程方式將提醒添加到提醒應用程序
我正在創建一個簡單的便箋應用程序,並且要實施提醒。用戶可以輸入筆記,點擊一個按鈕,然後使用該文本在提醒應用程序中設置提醒。這是可能的,如果是這樣,我該怎麼做?我看過Apple關於EventKit和EKReminders的文檔,但它一直沒有幫助。以編程方式將提醒添加到提醒應用程序
來自"Calendars and Reminders Programming Guide"?具體"Reading and Writing Reminders"
您可以使用該
reminderWithEventStore:
類方法提醒。title
和calendar
屬性是必需的。提醒的日曆是分組的列表。
,再創建一個提醒,要求准予:
在.h
:
@interface RemindMeViewController : UIViewController
{
EKEventStore *store;
}
和.m
,當你將需要訪問提醒:
store = [[EKEventStore alloc] init];
[store requestAccessToEntityType:EKEntityTypeReminder
completion:^(BOOL granted, NSError *error) {
// Handle not being granted permission
}];
實際添加提醒。這是異步發生的,所以如果你嘗試在此之後立即添加提醒,它將會失敗(根據我的經驗崩潰應用程序)。
- (IBAction)addReminder:(id)sender
{
EKReminder *reminder = [EKReminder reminderWithEventStore:store];
[reminder setTitle:@"Buy Bread"];
EKCalendar *defaultReminderList = [store defaultCalendarForNewReminders];
[reminder setCalendar:defaultReminderList];
NSError *error = nil;
BOOL success = [store saveReminder:reminder
commit:YES
error:&error];
if (!success) {
NSLog(@"Error saving reminder: %@", [error localizedDescription]);
}
}
http://www.techotopia.com/index.php/Using_iOS_6_Event_Kit_to_Create_Date_and_Location_Based_Reminders – Cezar 2013-04-07 16:21:32
謝謝這正是我一直在尋找。 – 2013-04-07 18:18:40