iphone - NSNotification issue: it's posted but just cached by one instance of the same class, why? -


here again:

what want is: if press button, post notification. notification should cached 2 instances of same class.

the problem:
notification posted, cached 1 instance.

some code , explanation
have 1 tab bar controller
have 3 tabs ( 3 different views -xib files-)
2 views references same (view controller) class (so, there 2 instances of same class, let's class a)
other tab/view references class (class b)

if press button of 1 view, method of class b fired and, @ point this:

[[nsnotificationcenter defaultcenter] postnotificationname:@"update" object:nil ]; 

in viewdidload method of class have this:

[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(updateall:) name:@"update" object:nil]; 

also, have defined updateall function as:

- (void) updateall: (nsnotification *) notification {     nslog(@"called"); } 

as said before, 1 time updateall method fired.

questions
why? how fix it?

thanks reading!

it possible view not loaded yet, because using tab bar controller. view not yet visible not loaded, viewdidload called 1 instance. recommend debug , make sure addobserver call executed twice, not once.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -