Local Notification

In Checklist App in local notifications section we added this let center = UNUserNotificationCenter.current() at two places: In AppDelegate and in the ChecklistItem object. Why?

You use UNUserNotificationCenter.current() to get a reference to the notification center. Then you can execute notification center methods on the instance you have a reference to.

In AppDelegate, after you get the reference, you have the line center.delegate = self which sets the AppDelegate as the delegate for receiving any notification center related events.

In ChecklistItem, you use the notification center reference to schedule notifications and to remove pending notifications.

Not sure why you think you shouldn’t have called it in two places though? The reason it was called in several places is to get a reference to the notification center at points where we need to perform actions affecting the notification center.

Does that clarify things? :slightly_smiling_face:

1 Like