Reputation: 1934
I am using the following code to create an event within the iPhone's calendar;
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);
Why is this saving an event with the name "DHSB Assignment: %@" rather than "DHSB Assignment: Example Text"?
Thank you.
Upvotes: 1
Views: 1063
Reputation: 57149
event.title = [NSString stringWithFormat:@"DHSB Assignment: %@", Assignment1.text];
Your current code is equivalent to
[event setTitle:@"DHSB Assignment: %@"];
[Assignment1 text];
…which is valid, so it compiles and runs fine even though it isn’t doing what you want.
Upvotes: 2