我从webservice获取了一系列字典和单字典。我将它们存储在一个nsmutablearray中并在uitableview中填充它们。我能够在tableview中填充字典数组但是我得到单个字典细节,它正在抛出一些麻烦。实际上,单个字典被存储为字典而不是字典数组。 现在有谁可以告诉我该怎么办?先谢谢。
编辑:这是我的代码,我正在解析数据
NSDictionary *filterNameDic;
for (filterNameDic in listOfFilterTypes)
{
if([[filterNameDic allKeys]count] > 1)
{
FilterType *filterTypeModel = [[FilterType alloc]init];
NSString *filterName = [filterNameDic objectForKey:@"FilterTypeName"];
filterTypeModel.FilterTypeName = filterName;
NSArray *filtersArray = [filterNameDic objectForKey:@"Filters"];
if(![filtersArray isKindOfClass:[NSDictionary class]])
{
NSMutableDictionary *tempDic;
for(tempDic in filtersArray)
{
for (key in [tempDic allKeys])
{
if (([key isEqualToString:@"DisplayName"] || [key isEqualToString:@"CodeName"]|| [key isEqualToString:@"Count"]))
{
FilterModel *filterMdl = [[FilterModel alloc]init];
[WebServiceClass storeValuesIn:filterMdl usingDictionary:tempDic];
[filterTypeModel.Filters addObject:filterMdl];
}
}
}
}
else
{
// for(key in [(NSDictionary *)filtersArray allKeys])
// {
// if (([key isEqualToString:@"DisplayName"]|| [key isEqualToString:@"CodeName"]|| [key isEqualToString:@"Count"]))
// {
FilterModel *filterMdl = [[FilterModel alloc]init];
[WebServiceClass storeValuesIn:filterMdl usingDictionary:(NSMutableDictionary *)filtersArray];
[filterTypeModel.Filters addObject:filterMdl];
// }
// }
}
[WebServiceClass storeValuesIn:filterTypeModel usingDictionary:filterNameDic];
NSLog(@"Filters%@",filterTypeModel.Filters);
[searchFilterArray addObject:filterTypeModel];
}
}
}
else
{
listOfFilterTypes = [[NSMutableArray alloc]initWithArray:filterDataArr];
FilterType *filterTypeModel = [[FilterType alloc]init];
[WebServiceClass storeValuesIn:filterTypeModel usingDictionary:(NSDictionary *)listOfFilterTypes];
[searchFilterArray addObject:filterTypeModel];
}
在uitableview的cellForRowAtIndexPath中
NSString *displayFiltername = [[[filterMdl Filters]objectAtIndex:indexPath.row]objectForKey:@"DisplayName"];
throwing an exception as
[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x9824fc0
Exception in CellRowIndexPath -[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x9824fc0