2010-04-08 3 views
0

Je suis en train d'envoyer un message sans beaucoup de succès! Je peux le faire ok pour le clavier sans problème, mais maintenant je tente une coutume comme un suit:Notification non reconnue

Dans mon rootview j'ai cette

.h

-(void) allowEdits:(NSNotification *)notification; 

.m

//this section is run in method to present the passcode entry form 


[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(allowEdits:) name: @"PasscodeOK" object:nil]; 

PasscodeEntryViewController *vc = [[PasscodeEntryViewController alloc] 
init]; 

[self presentModalViewController: vc animated:YES]; 

[vc release]; 


// and this is the response to the notification 

-(void) allowEdits:(NSNotification *)notification { 

    NSLog(@"notification fired"); 
} 


// in the vc instance I have this to notify passcode was ok 

[[NSNotificationCenter defaultCenter] 
postNotificationName:@"PasscodeOK" object:nil]; 

[self dismissView]; 

Mais le allowEdits n'est jamais appelé?

Répondre

0

Pourriez-vous essayer de poster votre notification avec:

[[NSNotificationCenter defaultCenter] postNotificationName:@"PasscodeOK" object:self]; 

Comme expéditeur prend l'exemple vc (auto) au lieu de zéro. Peut-être que c'est résoudre votre problème.

+0

Salut, ouais essayé avant mais pas de joie! Le problème est la méthode à appeler est dans le parent et la notification est postée dans l'enfant. De ce que je peux voir l'addObserver dans le parent est juste ignoré! Ça me rend fou!!! Je ne comprends tout simplement pas pourquoi ça ne marchera pas! – user7865437

+0

Eh bien enculé! Je l'ai trouvé après tout ce temps! Quand j'ai implémenté des notifications il y a des semaines, j'ai inclus dans la méthode viewDidDisappear un appel pour supprimer des observateurs! Donc à peine l'ai-je ajouté ... il a été retiré! DOH! – user7865437

Questions connexes