我使用以下代码在iPhone的日历中创建一个事件;
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.title = @"DHSB Assignment: %@", Assignment1.text;
event.startDate = [[NSDate alloc] init];
event.endDate = [[NSDate alloc] initWithTimeInterval:600 sinceDate:event.startDate];
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
[EKEventStore release];
NSLog(@"Successfully added '%@' to the calendar", Assignment1.text);
为什么这个名称为“DHSB Assignment:%@”的事件而不是“DHSB Assignment:Example Text”?
谢谢。
答案 0 :(得分:2)
event.title = [NSString stringWithFormat:@"DHSB Assignment: %@", Assignment1.text];
您当前的代码相当于
[event setTitle:@"DHSB Assignment: %@"];
[Assignment1 text];
...这是有效的,所以它编译并运行正常,即使它没有做你想要的。