As a favor to me, Greg has kindly allowed me to attach a simple class
for parsing and unparsing GDataRecurrence specifications. I've add it,
with unit test code, and a simple example to
http://code.google.com/p/gdata-objectivec-client/downloads/list The
interface is based on that used by the Macintosh Sync Services
Manager. He doesn't support it. I do.
In the official example CalendarHelloWorldMini, to create an event,
you say:
// begin common prefix.
// Construct the event we'll post.
GDataEntryCalendarEvent *event = [GDataEntryCalendarEvent
calendarEvent];
[event setTitleWithString:@"Hello World"];
NSTimeZone *currentTimeZone = [NSTimeZone defaultTimeZone];
NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0];
GDataDateTime *nowDateTime = [GDataDateTime dateTimeWithDate:now
timeZone:currentTimeZone];
NSDate *oneHourFromNow = [NSDate dateWithTimeIntervalSinceNow:
60*60];
GDataDateTime *endDateTime = [GDataDateTime
dateTimeWithDate:oneHourFromNow
timeZone:currentTimeZone];
// end common prefix.
GDataWhen *when = [GDataWhen whenWithStartTime:nowDateTime
endTime:endDateTime];
[event addTime:when];
In CalendarHelloWorldRecurring, you say, after the common prefix:
NSDictionary *recurrenceDict = [NSDictionary
dictionaryWithObjectsAndKeys:
nowDateTime, kStartDateKey,
endDateTime, kEndDateKey,
@"daily", kRecurrenceFrequencyKey,
[NSNumber numberWithInt:6], kRecurrenceCountKey,
nil];
NSString *recurrenceString = [[RecurrenceRFC2445 recurrence]
recurrenceStringFromDictionary:recurrenceDict];
GDataRecurrence *recurrence = [GDataRecurrence
recurrenceWithString:recurrenceString];
[event setRecurrence:recurrence];
That is, you construct a dictionary of key value pairs that define the
recurrence. use [RecurrenceRFC2445 recurrence] to turn it into a
string (use it once, then discard it. then pass that string, instead
of a GDataWhen to define when the event occurs.
You can look at RecurrenceRFC2445 .h and its unit tests for some of
the things you can put in the dictionary.
The recurrence dictionary Api is inspired by
http://developer.apple.com/documentation/AppleApplications/Reference/SyncServicesSchemaRef/Articles/Calendars.html
I've only tested it on Mac OS, but since it only uses Foundation, it
should be fine on iPhone OS.
-- DavidPhillipOster