我有一个NSArray
包含多个NSDictionary
从服务器获取的内容,我想迭代每个NSDictionary
被key's value
调用的内容"id"
,然后将它们添加到NSMutableArray
. 我曾经"for loop"
实现过这个功能,但是NSMutableArray
登录的Xcode debug area
结果很奇怪,而且不正确。
NSDictionary
这是在 a中迭代每个的代码NSArray
。
//Get the dictionary that included item ids.
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:&error];
//Create the array add item id objects.
NSMutableArray *itemIds = [NSMutableArray array];
//Fetching item ids in dictionary array.
NSArray *itemIdsDictionary = dictionary[@"itemRefs"];
NSLog(@"%i", [itemIdsDictionary count]);//Have valid dictionary.
for(int i = 0; i < [itemIdsDictionary count]; i++)
{
NSString *aId = (itemIdsDictionary[i])[@"id"];
[itemIds addObject:aId];
NSLog(@"%@", itemIds);
NSLog(@"%@", aId);
}
NSMutableArray
登录是Xcode degug area
:
2013-07-04 22:55:26.053 Readable[3222:c07] 5
2013-07-04 22:55:26.053 Readable[3222:c07] (
51d58c198e49d061db0011e3
)
2013-07-04 22:55:26.054 Readable[3222:c07] (
51d58c198e49d061db0011e3,
51d58c198e49d061db0011e4
)
2013-07-04 22:55:26.054 Readable[3222:c07] (
51d58c198e49d061db0011e3,
51d58c198e49d061db0011e4,
51d5745982d493d61500e706
)
2013-07-04 22:55:26.054 Readable[3222:c07] (
51d58c198e49d061db0011e3,
51d58c198e49d061db0011e4,
51d5745982d493d61500e706,
51d5745982d493d61500e707
)
2013-07-04 22:55:26.054 Readable[3222:c07] (
51d58c198e49d061db0011e3,
51d58c198e49d061db0011e4,
51d5745982d493d61500e706,
51d5745982d493d61500e707,
51d55fb04de3837bf3006e83
)
真的希望有人能帮我解决这个问题,这是我自己的应用程序中非常重要的阶段。谢谢!!!!!!