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"];
Was it helpful?

Solution

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

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

OTHER TIPS

char rate = [[userInfo objectForKey:@"baud"] charValue];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top