When I NSLog the array I get this:
当我NSLog数组我得到这个:
(
{
content = "content a";
id = 452069;
timestamp = 1313341470;
},
{
content = "content b";
id = 451498;
timestamp = 1313261505;
},
etc...
)
How do you refer to specific index's? For example how would you get the content for the second index.
你如何参考具体的指数?例如,如何获取第二个索引的内容。
I've tried [[myArray objectAtIndex:1]objectForKey:@"content"]
but that crashes the program.
我已经尝试[[myArray objectAtIndex:1] objectForKey:@“content”]但是这会导致程序崩溃。
Also doing [myArray objectAtIndex:1] crashes the program as well.
另外做[myArray objectAtIndex:1]也会使程序崩溃。
2 个解决方案
#1
2
According to your edit your array is likely over released. Make sure your array is properly retained, if it uses a property make sure the property is set to copy
or retain
and if you set it internally be sure to use self.myArray = ...;
and not myArray = ...'
.
根据您的编辑,您的阵列可能已过度发布。确保您的数组已正确保留,如果它使用属性,请确保该属性设置为复制或保留,如果您在内部设置它,请确保使用self.myArray = ...;而不是myArray = ......'。
#2
-1
Have you tried -valueForKey:
? The item at that index is not an object but a value.
你试过-valueForKey:?该索引处的项目不是对象而是值。
#1
2
According to your edit your array is likely over released. Make sure your array is properly retained, if it uses a property make sure the property is set to copy
or retain
and if you set it internally be sure to use self.myArray = ...;
and not myArray = ...'
.
根据您的编辑,您的阵列可能已过度发布。确保您的数组已正确保留,如果它使用属性,请确保该属性设置为复制或保留,如果您在内部设置它,请确保使用self.myArray = ...;而不是myArray = ......'。
#2
-1
Have you tried -valueForKey:
? The item at that index is not an object but a value.
你试过-valueForKey:?该索引处的项目不是对象而是值。