1

I have been doing a great deal of work using Notifications in few of my apps, at first they gave me random crashes but then I learned about the best way to use NSNotifications and here are a few best practices that I learnt.

---remove the observe's when they are of no use.

---remove the observer's before they are deallocated, leads to random crashes.

---Do not add two observers methods in the same class for the same notification.

If I am wrong or If I miss anything feel free to add up. What I want now is when I post a notification can I see the list of observer's waiting to receive my notificaton and can I selectively post to a set of observer's by missing out some intentionally?.

I also saw this Thread that is quite similar. I am creating a new thread because I want to dig up more with Notifications. I expect good contributions.

Community
  • 1
  • 1
Satheesh
  • 10,998
  • 6
  • 50
  • 93
  • 2
    I think the answer in the thread you linked to is pretty good. The object that posts the notification doesn't know (and shouldn't know) anything about the receivers. If you want a more selective way to communicate between objects, you should probably use delegates. – rdelmar Apr 07 '13 at 18:36
  • ideally, the observer and the poster should not know each other at all. – Bryan Chen Apr 08 '13 at 00:41
  • Yes that is right, is there any way that I could subclass NSNotifications and do it in this way? – Satheesh Apr 08 '13 at 03:49

0 Answers0