KNContactsSchedule
public struct KNContactsSchedule
A collection of contact identifier strings grouped by a time format to create contact schedules. Can be used for persisting the IDs to a store or to User Defaults.
Version
1.0.0-
The name of the schedule
Declaration
Swift
public let name: String
-
The time format to save the schedule in
Declaration
Swift
public let format: KNDateTimeFormat
-
Initialises a
KNContactSchedule
with a name and time format.Version
1.0.0
Declaration
Swift
public init(name: String, format: KNDateTimeFormat = .fullDate)
Parameters
name
The name of the contact schedule.
format
The
KNTimeFormat
value to be used for grouping the contact identifiers by and later be retrieved. Optional. Defaults toKNTimeFormat.fullDate
-
Adds multiple contact identifers to the schedule for a particular day passed as Date type.
Version
1.0.0
Declaration
Swift
public mutating mutating func add(list: [String], to day: Date)
Parameters
list
An array of strings representing contact identifiers. Required.
to
The Date value to be used for grouping the contact identifiers by and later be retrieved.
-
Adds multiple contact identifers to the schedule for a particular day passed as a String type. The string representing a datetime format will be parsed and if invalid, the method will return without adding the identifiers to the schedule.
Version
1.1.0
Declaration
Swift
public mutating mutating func add(list: [String], to day: String)
Parameters
list
An array of strings representing contact identifiers. Required.
fromString
A string value representing a valid date format to be used for grouping the contact identifiers by and later be retrieved.
-
Retrieves the whole schedule.
Version
1.0.0Declaration
Swift
public func getSchedule() -> [String : [String]]
Return Value
A dictionary of date strings, each holding the schedule of contacts as an array of contact identifers for that date.
-
Retrieves the schedule for a particular day
Version
1.0.0
Declaration
Swift
public func getSchedule(for day: Date) -> [String]
Parameters
day
A Date representing the day for which day to retrieve the schedule for.
Return Value
The schedule of contacts as an array of contact identifiers strings for the specified date.
-
Retrieves the schedule for the current day.
Version
1.0.0Declaration
Swift
public func scheduleForToday() -> [String]
Return Value
The schedule of contacts as an array of contact identifiers strings for the current date.
-
Resets the schedule by invalidating the stored schedule collection.
Version
1.0.0Declaration
Swift
public mutating mutating func reset()