Je voudrais passer dict à la méthode processit. Mais une fois que j'accède au dictionnaire, j'obtiens EXC__BAD_INSTRUCTION.Comment utiliser la méthode paramétrée avec NSNotificationCenter?
NSNotificationCenter *ncObserver = [NSNotificationCenter defaultCenter];
[ncObserver addObserver:self selector:@selector(processit:) name:@"atest"
object:nil];
NSDictionary *dict = [[NSDictionary alloc]
initWithObjectsAndKeys:@"testing", @"first", nil];
NSString *test = [dict valueForKey:@"first"];
NSNotificationCenter *ncSubject = [NSNotificationCenter defaultCenter];
[ncSubject postNotificationName:@"atest" object:self userInfo:dict];
Dans la méthode bénéficiaire:
- (void) processit: (NSDictionary *)name{
NSString *test = [name valueForKey:@"l"]; //EXC_BAD_INSTRUCTION occurs here
NSLog(@"output is %@", test);
}
Toutes les suggestions sur ce que je fais mal?
Merci Adrian pour mettre à jour le code. Je prendrai soin du formatage aussi, de la prochaine fois. :) –