Question

In my NSNotificationCenter I have something like:

    NSMutableDictionary *info = [NSMutableDictionary dictionaryWithCapacity:1];
    [info setObject:[NSNumber numberWithChar:cmd[3]] forKey:@"baud"];
    [[NSNotificationCenter defaultCenter]postNotificationName:@"baud" object:nil userInfo:info];

Now I would like to have this char back. I need something like:

NSDictionary *userInfo = [note userInfo];
char rate = [userInfo objectForKey:@"baud"];
Était-ce utile?

La solution

You are packing the char into an NSNumber, so you need to extract it again:

char rate = [(NSNumber *)[userInfo objectForKey:@"baud"] charValue];

Autres conseils

char rate = [[userInfo objectForKey:@"baud"] charValue];
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top