【发布时间】:2009-09-22 22:42:34
【问题描述】:
我有一个使用 plist 初始化的 NSDictionary,其中包含 count 后跟 32,我想获取 count 的值。
怎么做?
我知道如何通过
将其放入对象中[dictionaryObjectName objectForKey:@"count"]
但对我来说,我得到的价值并不是一个对象。
如果我必须指定一个对象,最好使用什么(仅供参考,该值将始终是无符号的),我需要将其转换为真正的 int。
我会做类似的事情
NSNumber *num = [dictionaryObjectName objectForKey:@"count"];
int theValue = [num intValue];
[num release];
对于没有垃圾收集器的 iPhone 来说,在 num 上发布是一件好事吗?
【问题讨论】:
-
int theValue = [num intValue]; // 是一个 'int' AND NSInteger theValue = [num integerValue]; // 是一个 NSInteger
标签: iphone nsdictionary