0
[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(requestAddressUpdatedNotification:) 
                                             name:MTAddressUpdatedNotification 
                                           object:nil];

Can anyone tell me what will happen if I write this piece of code in my program ?

And when will the method requestAddressUpdatedNotification be called?

David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205
generalzyq
  • 303
  • 3
  • 11

1 Answers1

4

The code informs the default NSNotificationCenter to notify your object (self) when a MTAddressUpdatedNotification NSNotification occurs and to trigger requestAddressUpdatedNotification: method which must be defined (within @implementation…@end) in the same class.

F. Orvalho
  • 576
  • 4
  • 12
Global nomad
  • 1,037
  • 12
  • 25
  • So you mean if MTAddressUpdatedNotification occurs and requestAddressUpdatedNotification will be called? – generalzyq Aug 14 '12 at 08:46
  • Yes, when a MTAddressUpdatedNotification is posted, your requestAddressUpdatedNotification: will be triggered or in Objective-C parlance "receive a message". – Global nomad Aug 14 '12 at 08:50