Just like in the normal iPhone calendar app, I need to make a table view which has the users calendar which they can select one and then use that and save the event to that calendar.
Any help would be much appreciated, as there doesn't seem to be much info on this around.
Thanks.
You want to check out the Event Kit Programming Guide, especially the part on Creating and Editing Events Programatically.
You basically want to allocate and initialize an EKEventStore, and use the calendars property to get the list of calendars. It's an array of EKCalendar objects.
To show them in a table, you'll end up with something like:
// eventStore is an EKEventStore instance variable which was alloc/init'ed elsewhere
- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
return [eventStore.calendars count];
}
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
UITableViewCell* aCell = [tableView dequeueReusableCellWithIdentifier:@"MyCell"];
if( aCell == nil ) {
aCell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier:@"MyCell"] autorelease];
}
EKCalendar* aCalendar = [eventStore.calendars objectAtIndex:[indexPath row]];
aCell.textLabel.text = aCalendar.title;
return aCell;
}
You could also consider using EKEventStore's defaultCalendarForNewEvents, rather than having your own UI to choose.