ios - Should I remove notification for NSUbiquitousKeyValueStoreDidChangeExternallyNotification -
i using tutorial started:
http://www.raywenderlich.com/63269/how-to-save-your-game-data-tutorial-part-2-of-2
i have use it, implemented , test , working fine.
here found notification should removed in dealloc (at end of article)
http://subjective-objective-c.blogspot.com/2011/04/avoid-nsnotification-removeobserver.html
my question should remove notification nsubiquitouskeyvaluestoredidchangeexternallynotification? , in method ?
in general, notification, stop observing when no longer care notification. 1 case don't care more when object observing notification gets deallocated.
what second article telling removeobserver:
not best choice. removes observer all notifications. includes notifications registered notifications frameworks use internally. article explains, it's better use removeobserver:name:object:
explicitly unregister each notification. it's not telling you should unregister notifications in dealloc
, it's telling you should unregister notifications using removeobserver:
method in dealloc. that's advice, it's ok use other remove-observer methods wherever need use them.
that means want unregister in dealloc
, depends on code , on when need receive notifications.
Comments
Post a Comment