我正在尝试向数组添加字典以在字典上创建数组,但是当我测试应用程序时,该数组仍然为空。看一下我的代码:
NSMutableArray *listaEstabelecimentosPorCategoria;
for (NSDictionary *tempDict in listaEstabelecimentos) {
if ([[tempDict objectForKey:@"category"] integerValue] == 1) {
[listaEstabelecimentosPorCategoria addObject:tempDict];
NSLog(@"TEST");
}
}
NSLog(@"%@", listaEstabelecimentosPorCategoria);
该应用程序将打印以下内容:
2013-08-18 12:16:38.802 Petrópolis[10157:c07] TEST
2013-08-18 12:16:38.802 Petrópolis[10157:c07] TEST
2013-08-18 12:16:38.803 Petrópolis[10157:c07] (null)
最佳答案
当我测试应用程序时,数组仍然为空。
这是因为您没有初始化listaEstabelecimentosPorCategoria
:
NSMutableArray *listaEstabelecimentosPorCategoria = [NSMutableArray array];