views:

85

answers:

1

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 name:OBSERVER_NAME object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(selectorName) name:OBSERVER_NAME object:nil]; }

The reason is to prevent two observers with the same selectorName method being called twice assuming that setObserver method was called again if its inside viewdidload and a memory warning was issued.

Also, do i need to inoke removeobserver during dealloc?

A: 

thanks! thanks! thanks!

Mark