我有一个 Iphone 应用程序,我在其中从字典向数组添加值。谁能告诉我在迭代字典之前如何检查字典是否存在?
NSDictionary *news=[dict objectForKey:@"news"];
NSDictionary *deals=[dict objectForKey:@"deals"];
NSLog(@"%@",[news classForCoder]);
NSLog(@"%@",news);
NSLog(@"%@",deals);
for(NSDictionary *key in news)
{
if([key isKindOfClass:[NSDictionary class]])
{
[dataArray addObject:key];
}
// NSLog(@"%@",rewardsId);
//[dataArray addObject:dictrewards];
}
for(NSDictionary *key in deals)
{
if([key isKindOfClass:[NSDictionary class]])
{
[dataArray1 addObject:key];
}
// NSLog(@"%@",rewardsId);
//[dataArray addObject:dictrewards];
}
self.newsseperatearray=dataArray;
self.dealsseperatearray=dataArray1;
self.newssarray = [[dataArray arrayByAddingObjectsFromArray:dataArray1] mutableCopy];
NSLog(@"%@",self.newssarray);
//self.newssarray=dataArray;
[self.mTableView reloadData];