Sync EKRecurrenceRules with the RFC 2445 Cloud Service iCalendar RRULE Specification

I am trying to create a cloud service that stores recurring events. I decided to do this using icalendar RRULE standards (RFC2445) and use the database schema as shown below through the cloud service.

 EventID EventName EventDescripton Start End RecurrenceRule <-- Store RFC 2445 iCalendar specification RRULE (recurrence) Active Deleted DateCreated DateLastUpdated 

I believe that EKRecurrenceRules compatible with RFC 2445, however, preserving the RRULE string representation or the EKRecurrenceRule description makes it more cross-platform compatible.

I can easily create an EKRecurrenceRule on the client side and extract the RRULE from the description property of the EKRecurrenceRule. However, my question is how to convert this description property back to an EKRecurrenceRule object on the client when retrieving from the cloud service? It seems like stupid Apple will RRULE property to retrieve compatible RRULE , but it will not provide any way to convert RRULE to its own object.

I would like to avoid storing the individual components of the EKRecurrence rule, if possible.

+4
source share
2 answers

you can use this library: https://github.com/FabienDiTore/ios-rrule_parser

to create an EKRecurrenceRule. If yes, let me know.

+2
source

... extract RRULE from the description property of EKRecurrenceRule

It seems fraught with danger. The documentation for -[id<NSObject> description] ensures that it returns a "string that describes the contents of the recipient" - the EKRecurrenceRule implementation may not give the proper RRULE in the future, or it may change slightly that the "extract" RRULE will not work. (This is probably why Apple does not provide anything to convert RRULE back to EKRecurrenceRule - they did not mean that you could extract and work with RRULE in the first place.)

It seems to me that the best solution would be to find or write a library or EKRecurrenceRule category that provides the appropriate accessory - (NSString *)rrule and, possibly, the corresponding - (id)initWithRRule:(NSString *)rrule initializer. This way you can not rely on undocumented behavior and be sure that you can convert between instances of RRULE and EKRecurrenceRule the way you want.

0
source

Source: https://habr.com/ru/post/1441100/


All Articles