IOS - event dialing programming for listening to notifications

I want to watch for changes in the Calendar application, so I am logging an EKEventStoreChangedNotification notification. But do I need an EKEventStore live object to receive this notification? I think I initialize the EKEventStore object in the view controller to receive some events. And then I will lay out this view controller of the navigation stack, and the view manager will be freed, so the EKEventStore object will be freed.

+2
source share
2 answers

No, you do not need to keep the EKEventStore alive because you are already registering the EKEventStoreChangedNotification using an EKEventStore named eventStore

 [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(storeChanged:) name:EKEventStoreChangedNotification object:eventStore]; 

Contact this for more resolution of your doubts.

+2
source

For quick 3.x use as below

 NotificationCenter.default.addObserver(self, selector: #selector(ViewController.storeChanged(_:)), name: NSNotification.Name.EKEventStoreChanged, object: eventStore) ... ... ... //Method func storeChanged(_ nsNotification: NSNotification) { //do your stuff } 
0
source

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


All Articles