我想添加一個字典到數組中以在字典上創建數組,但是當我測試應用程序時,數組仍然是空的。就以我的代碼來看看:無法將NSDictionary添加到NSArray
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)
你忘了初始化你的數組。 –