【发布时间】:2012-06-17 12:35:43
【问题描述】:
我今天遇到了一个意外错误。我有一个NSArray 和一个NSMutableDictionary。问题是我的NSMutableDictionary 变成了一个数组。代码如下:
标题:
NSArray *tableViewCellValues;
NSMutableDictionary *inputValues;
实现:
- (void)viewDidLoad
{
[super viewDidLoad];
tableViewCellValues = [NSArray arrayWithObjects:@"First", @"Second", @"Third", nil];
inputValues = [NSMutableDictionary dictionary];
//other code...
}
所以通常我应该得到一个以“First”、“Second”和“Third”作为对象的数组和一个空的NSMutableDictionary。当我在初始化NSMutableDictionary 后立即在日志中打印它时,我得到以下信息:
(lldb) po tableViewCellValues
(NSArray *) $1 = 0x00000000 <nil>
(lldb) po inputValues
(NSMutableDictionary *) $2 = 0x06a80420 <__NSArrayI 0x6a80420>(
First,
Second,
Third
)
(lldb) po [tableViewCellValues class]
error: Couldn't execute function; result was eExecutionDiscarded
(lldb) po [inputValues class]
(id) $4 = 0x01453b64 __NSArrayI
我有点困惑。我尝试清理并再次运行它,但没有任何反应。
如果重要的话,我正在使用 Mac OS X 10.7.3 和 Xcode 4.3。
任何帮助将不胜感激。
【问题讨论】:
-
你试过用alloc和init来初始化你的字典吗?
[[NSMutableDictionary alloc] init] -
@skram 我做了,但没有任何区别
-
您在使用 ARC 吗?如果没有,则必须同时保留数组和字典
标签: iphone objective-c ios nsarray nsmutabledictionary