Michael Grant

Michael Grant

SwiftUI class notes 2021-12-12

Friese’s Task model:

enum TaskPriority {
  case high
  case medium
  case low
}

struct Task: Identifiable {
  var id: String = UUID().uuidString
  var title: String
  var priority: TaskPriority
  var completed: Bool
}

By contrast, Apple’s native EKReminder is a class that inherits from EKCalendarItem, which in turn inherits from EKObject. Its accessible properties:

  • EKReminderPriority (an enum with values none, high, medium, and low)
  • priority: Int
  • startDateComponents: DateComponents?
  • dueDateComponents: DateComponents?
  • isCompleted: Bool
  • completionDate: Date?

And accessible properties inherited from EKCalendarItem:

  • calendarItemIdentifier: String
  • calendarItemExternalIdentifier: String! — external identifier as provided by the calendar server
  • calendar: EKCalendar!
  • title: String!
  • location: String?
  • creationDate: Date?
  • lastModifiedDate: Date?
  • timeZone: TimeZone?
  • url: URL?
  • hasNotes: Bool
  • notes: String?
  • hasAttendees: Bool — so a reminder can have attendees?
  • attendees: [EKParticipant]?
  • hasAlarms: Bool
  • alarms: [EKAlarm]?
  • hasRecurrenceRules: Bool
  • recurrenceRules: [EKRecurrenceRule]?

The EKObject class’s properties, booleans hasChanges and isNew, relate to saving and restoring state.

¿Why two different priority properties?
¿Why simply completionDate and not completionDateComponents?