EventDictionaryParser
public struct EventDictionaryParser : EventParser
Default implementation of the EventParser
protocol.
Parse event data from json. Each key from JSON represents property name from the the EKEvent
type.
Example:
{
"title": "Minimal Event Title",
"startDate": "2017-01-22 13:45:00",
"endDate": "2017-01-22 14:30:00"
}
Seealso
EventKitHandler
Seealso
For full example checkevents.json
file in the test project.
-
Events store used to create and save events.
Declaration
Swift
public var eventStore: EKEventStore!
-
Calendar in which events will be saved.
Declaration
Swift
public var calendar: EKCalendar?
-
Initializes parser with event store and calendar.
Declaration
Swift
public init(with eventStore: EKEventStore, calendar: EKCalendar? = nil)
Parameters
eventStore
Events store used to create and save events.
calendar
Calendar in which events will be saved. If
nil
, thedefaultCalendarForNewEvents
will be used. -
Initializes parser without event store and calendar.
Note
EKEventStore is implicitly unwrapped, so it needs to be set anyway before parsing attempt.Declaration
Swift
public init()
-
Parses JSON dictionary and returns parsed
EKEvent
object.Declaration
Swift
public func parse(_ json: [String : Any]) throws -> EKEvent
Parameters
data
JSON dictionary to parse.
Return Value
Parsed event.