2011-04-14 3 views
0

내 startDate 및 endDate를 설정하려고 할 때 계속 오류가 발생합니다. 여기서 내가 뭘 잘못하고 있니? 나는 확실히 누군가가이 오류와 함께 나를 도울 수 있기를 바랍니다iPhone의 이벤트 키트에 이벤트를 저장할 수 없습니다.

EKEventStore *eventStore = [[EKEventStore alloc] init]; 
EKEvent *newEvent = [EKEvent eventWithEventStore:eventStore]; 

NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init]; 
[dateFormatter setDateFormat:@"yyyy-MM-dd:HH:mm"]; 

NSString *fechainicio = @"2011-04-13:22:30"; 
NSString *fechafin = @"2011-04-14:24:00"; 

NSDate * date = [[NSDate alloc] init]; 
date = [dateFormatter dateFromString:fechainicio]; 
NSDate * date2 = [[NSDate alloc] init]; 
date2 = [dateFormatter dateFromString:fechafin]; 

[date2 retain]; 
[date retain]; 
[fechainicio retain]; 
[fechafin retain]; 

newEvent.title = @"title"; 
newEvent.startDate = date; 
newEvent.endDate = date2; 

[newEvent setCalendar:[eventStore defaultCalendarForNewEvents]]; 
NSError *err; 
[eventStore saveEvent:newEvent span:EKSpanThisEvent error:&err]; 

if (err != nil) 
{ 
    NSLog(@"error"); 
} 

그것은 나에게 미친 XD를 운전하는 것 : 여기 내 코드입니다. 감사.

답변

1
NSString *fechainicio = @"2011-04-13:22:30"; 
NSString *fechafin = @"2011-04-14:24:00"; 

이 날짜의 형식이 올바르게 지정 되었습니까? 그 세 번째 값은 그 달의 날짜인가 그시의 시간인가? 이들은 아마도 잘못되었습니다. 비록 내가 왜 당신이 기록 된 오류에서 그것을 보지 않고 있는지 모르겠지만 ...

+0

Genius !!! 나는 잘못 포맷 했어, 고마워 !!!! – 0SX

+1

천재가 아닙니다. 그냥 신선한 눈 세트. –