NSNotification postNotificationName en AppDelegate pero NSNotificationCenter en ViewController?
No puedo obtener el método selector, recibirChatText, en el NSNotificationCenter para ejecutar y me pregunto si el problema se debe a que NSNotification postNotificationName está en AppDelegate.m pero NSNotificationCenter está en ViewController.m. ES DECIR. ¿puede saber postNotificationName saber que NSNotificationCenter está en otro archivo viewController o es algo que necesito decirle?
En un viewController.m tengo
-(id)init
{
self = [super init];
if(self){
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(receiveChatText:)
name:ChatMessageReceived
object:nil];
return self;
}
- (void)receiveChatText:(NSNotification *)note {
NSLog(@"received chat text");
}
y en el archivo AppDelegate.m de nivel superior tengo lo siguiente:
-(void) didReceiveMessage {
[[NSNotificationCenter defaultCenter] postNotificationName:ChatMessageReceived
object:nil
userInfo:nil];
}
¿Alguna idea de lo que podría detener la recepción de executeChatText cuando se llamó aReceiveMessage?