iphone - NSNotification removeObserver problem -
i either brain damaged or lacking of understending of nsnotificationcenter
the problem if create observer , in next line try delete so:
[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(removeallvisiblemapviews) name:@"clearvisiblemaps" object:nil]; [[nsnotificationcenter defaultcenter] removeobserver:self forkeypath:@"clearvisiblemaps"];
i
*** terminating app due uncaught exception 'nsrangeexception', reason: 'cannot remove observer <myapp 0x592db70> key path "clearvisiblemaps" <nsnotificationcenter 0x4e0fbb0> because not registered observer.'
i add , remove observer line after line make point. in code using remove in dealloc.
so ideas why tell me didn't add , observer in first place?
you're removing observer keypath, not notification name. removal should this:
[[nsnotificationcenter defaultcenter] removeobserver:self name:@"clearvisiblemaps" object:nil];
Comments
Post a Comment