tags:

views:

29

answers:

1

hi, i am new Notification.what is the purpose of it... can we use [[NSNotificationCenter defaultCenter] addObserver without postNotification, If we can do it,how it is identified?what is the relationship between addObserver and postNotification?any one can explain in detail?

+1  A: 

it's rather straight forward: you define an event by giving it a unique name, then you add an observer to it using [[NSNotificationCenter defaultCenter] addObserver and point it to a selector that receives the event.

then later on in your code you can postNotification and if the unique name matches the one you registered for - the selector you provided will be called.

Reflog
[[NSNotificationCenter defaultCenter] addObserver is one view controller....postnotifaction and selector method is in one view controller..will it work?
Mikhail Naimy
Absolutely. defaultCenter is shared for the whole application.
Reflog