我正在开发一个应用程序,因为我已经收集了来自webService的数据,现在我想将该特定信息存储到日历中,以便我遵守以下代码编写的日期
self.eventStore = [[EKEventStore alloc ] init ];
event = [EKEvent eventWithEventStore:eventStore];
Detail *detail1=[DetailArray objectAtIndex:indexPath.row];
//-------------------------------------------------------
// Get an array of all the calendars.
calendars = eventStore.calendars;
// Get the default calendar, set by the user in preferences.
EKCalendar *defaultCal = eventStore.defaultCalendarForNewEvents;
// Find out if this calendar is modifiable.
isDefaultCalModifiable = defaultCal.allowsContentModifications ;
self.event = [ EKEvent eventWithEventStore:eventStore ];
self.event.title = detail1.companyname;
//self.event.location = @"Pune" ;
//NSDate *today = [NSDate date];
//date=[[NSDate alloc] init];
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"dd/MM/yyyy"];
NSString *dateStart1 = detail1.filedate;//[formatter stringFromDate:date];
NSDate *dateStart =[formatter dateFromString:dateStart1] ;
NSDate *dateEnd = [formatter dateFromString:dateStart1];
self.event.startDate = dateStart;
self.event.endDate = dateEnd;
self.event.calendar = defaultCal ;
NSError *error;
saved = [self.eventStore saveEvent:self.event span:EKSpanThisEvent error:&error];
//-------------------------------------------------------
但在完成此代码后,应用终止或提供EXC-BAD ..
所以任何人都可以为我提供解决方案,或者为我提供示例代码的解决方案。
感谢。 普里....