I'm building a small calendar application where a user can select which calendar the events should be entered into. So the users picks their calendar of choice from a pickerview in the settingsmodal, then when they enter a new event I should be able to get that calendar object to create the event some how. I tried writing the object to a plist, by putting it in a NSDictionary but I don't think its able to store objects of that type. Can I save the name and calendartype of the calendar and somehow get the EKCalendar-object with those two paramaters? Preferably without having to manually loop through them all.
Also, how do I programmatically create new calendarevents? I have the following information about each event; start-time is Now, end-time in a minute-value from the startingpoint, if its a full day, the calendar (if I can get the top bit to work) and the event name.
Thanks in advance, Christopher.
I suggest that you read the EventKit Programming Guide first. It explains how to create and save new events.
If you want to save information about the selected calendar and retrieve the calendar later from that information, you can use the calendarIdentifier
property of EKCalendar
in conjunction with the -calendarWithIdentifier:
method of EKEventStore
:
// Save the identifier
NSString *identifier = [aCalendar calendarIdentifier];
...
// Retrieve the calendar later
NSString *identifier = ...;
EKCalendar *aCalendar = [eventStore calendarWithIdentifier:identifier];