ios - How to create new list of reminder from code(objective c) on "reminder app" of iphone -
i want create new list of reminder code(objective c) on "reminder app" of iphone. if possible please let me know.
warm regard, thanks
you can create reminders using reminderwitheventstore: class method. title , calendar properties required. calendar reminder list grouped.
before create reminder, ask permission:
in .h:
@interface remindmeviewcontroller : uiviewcontroller { ekeventstore *store; }
and .m, when going need access reminders:
store = [[ekeventstore alloc] init]; [store requestaccesstoentitytype:ekentitytypereminder completion:^(bool granted, nserror *error) { // handle not being granted permission }];
to add reminder. happens asynchronously, if try add reminder after this, fail (crashes app in experience).
- (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]); } }
for further details check tutorial.
Comments
Post a Comment