addobserver

Possible locations to call addObserver and removeObserver methods

I have a case where the child view sends notification to parent view. Now i'm calling addObserver in viewWillAppear and remove Observer in viewWillDisappear. But, i'm guessing this is not correct since viewWillAppear calls when view is refreshed. [[NSNotificationCenter defaultCenter] addObserver:<#(id)observer#> selector:<#(SEL)aSelect...

How to specify notificationSender? (Cocoa Touch)

All of the examples I can find of setting up a notification look like this: [nc addObserver:self selector:@selector(keyboardWillShow:) name: UIKeyboardWillShowNotification object:nil]; where object is always being set to nil. object is the notificationSender, which is defined thusly in the documentation: "The object whose notification...

Observing CLLocationCoordinate2D in iphone SDK

Hi Team, In iPhone SDK, can we only observe Objects, and not struts like CLLocationCoordinate2D? Example: I've got some very simple code where I'd like to observe a property of type CLLocationCoordinate2D, I've made sure to synthesize it in ABC.m. @interface ABC { CLLocationCoordinate2D currentLocation; } @property (nonatomic, readwr...

addobserver / removeobserver query

Hi, is it ok to use removeobserver first and then call addobserver call with the same name? Or is it a rule to have addobserver first before removeobserver? I tried it using OS 4.0 and it seems ok ( no crash, warnings.. etc).. -(void) setObserver { [[NSNotificationCenter defaultCenter] removeObserver:self ...