-1

使用ARC时,在创建for循环中的NSDictionaries时遇到了很大的麻烦。关键是,第一个“字典”创建后,应用程序崩溃给予EXC_BAD_ACCESS,所以我认为这是与对象的释放相关的东西,但无法弄清楚什么!我试图用一个autoreleasepool但结果是一样的使用ARC在循环中创建NSDictionary

for (int i = 0; i < [arr1 count]; i++) { 
     __strong NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[arr1 objectAtIndex:i], @"name", [arr4 objectAtIndex:i], @"position", [arr2 objectAtIndex:i], @"number", [arr5 objectAtIndex:i], @"status", [[arr6 objectAtIndex:i] intValue], @"order", nil]; 
     [pl_stuff addObject:dict]; 
} 

感谢您的答复

+0

是什么pl_stuff? – 2012-08-06 12:53:58

+0

arr1的内容是什么 – NIKHIL 2012-08-06 12:56:06

+0

pl_stuff是一个数组,问题是,正如弗拉基米尔提到的那样,我在插入到数组中的字典中添加了一个int。感谢您的快速回答 – 2012-08-06 12:59:29

回答

4
[[arr6 objectAtIndex:i] intValue] 

你试图纯整数值添加到您的阵列,但阵列只接受Objective-C对象。你应该见好就收,作为:

[arr6 objectAtIndex:i] 
+0

oh gosh,我没有想到在字典中插入一个int,然后在数组中插入字典的问题。那是这个问题,非常感谢 – 2012-08-06 12:58:06