Reputation: 41
I'm trying to create a cloud based service which stores recurring Events. I have chosen to do this using the icalendar RRULE
standards (RFC2445) and use a database schema as below exposed via cloud based service.
EventID
EventName
EventDescripton
Start
End
RecurrenceRule <-- Store RFC 2445 iCalendar specification RRULE (recurrence)
Active
Deleted
DateCreated
DateLastUpdated
I beleive that the EKRecurrenceRules
are RFC 2445 compliant, however by storing the string representation of the RRULE
or description of the EKRecurrenceRule
makes for a more cross platform compliant architecture.
I am able to create a EKRecurrenceRule
on the client side easily and extract the RRULE from the EKRecurrenceRule description property. However, my question is how to convert that description property back to an EKRecurrenceRule
object on the client when extracted from the cloud service? It seems stupid Apple would expose a property to extract the compliant RRULE
but not provide any way to convert an RRULE
to a native object.
I'd like to avoid storing individual components of the EKRecurrence
rule if possible.
Upvotes: 4
Views: 762
Reputation: 60140
...extract the RRULE from the EKRecurrenceRule description property
This seems fraught with peril. The documentation for -[id<NSObject> description]
only guarantees that it returns "a string that describes the contents of the receiver" - EKRecurrenceRule's implementation might not give a proper RRULE in the future, or might change just barely enough that "extracting" the RRULE won't work. (This is probably why Apple doesn't provide anything to convert an RRULE back to an EKRecurrenceRule - they didn't mean for you to be able to extract and work with the RRULE in the first place.)
It seems to me that a better solution would be to find or write a library or EKRecurrenceRule category that provides a proper - (NSString *)rrule
accessor and perhaps a corresponding - (id)initWithRRule:(NSString *)rrule
initializer. That way, you can avoid relying on undocumented behavior and be confident that you can convert between RRULEs and EKRecurrenceRule instances in the way that you want.
Upvotes: 1
Reputation: 2164
you might be able to use this library: https://github.com/FabienDiTore/ios-rrule_parser
to create an EKRecurrenceRule. If you do, please let me know.
Upvotes: 2