在将int值放入字典之前我已将int值设置为[NSNumber numberWithInt:2],现在当我尝试检索字典内容时,我希望它以int格式返回.. hw这样做?
这是我的代码;
NSMutabelDictionary *dict = [[NSMutableDictionary alloc]init];
int intValue = 300;
[dict setObject:[NSNumber numberWithInt:intValue] forKey:@"integer"];
Run Code Online (Sandbox Code Playgroud)
retriving .........
int number = [dict ObjectForKey:@"integer"];
Run Code Online (Sandbox Code Playgroud)
..它抛出异常,说铸造是必需的..当我这样做的时候..
int number = (int)[dict ObjectForKey:@"integer"];
Run Code Online (Sandbox Code Playgroud)
它不起作用......
如何解决这个问题呢?/
请建议..