_NSArrayM isEqualToString:]:无法识别的选择器发送到实例0x8d70f00

时间:2014-08-13 08:36:06

标签: ios objective-c uitableview nsdictionary

我有NSDictionary与键及其值,我希望它填充到tableview但我得到这样的错误:

  -[__NSArrayM isEqualToString:]: unrecognized selector sent to instance 0x8f8e4d0
2014-08-13 13:29:45.357 SotaApp[1602:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM isEqualToString:]: unrecognized selector sent to instance 0x8f8e4d0'  
我试过的是:

NSString *value = [filteredDictionaryValues valueForKey:[filteredDictionaryValues.allKeys objectAtIndex:indexPath.row]];

cell.textLabel.text =[filteredDictionaryValues.allKeys objectAtIndex:indexPath.row];
cell.detailTextLabel.text = value;

请告诉我这是什么问题, 谢谢。

修改 字典看起来像这样:

activity =     (
    "0Pharmacology.html"
);
acute =     (
    "0Pharmacology.html"
);
adenosine =     (
    "0Guidelines Precautions.html"
);
administration =     (
    "0Guidelines Precautions.html"
);
aneurysm =     (
    "0Dilution for Infusion.html"
);
arrhythmias =     (
    "0Guidelines Precautions.html"
);
artery =     (
    "0Dilution for Infusion.html"
);
asthma =     (
    "0Guidelines Precautions.html"
);
atrium =     (
    "0Dosing.html"
);

我已经从搜索方法中过滤了字典:

-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText

{

if (searchText.length == 0) {
    isSearching = NO;
}
else{
    isSearching = YES;
}





 NSPredicate *predicate =[NSPredicate predicateWithFormat:@"self beginswith[c]    %@",searchText];

NSArray *filteredKeys =[[myDictionary allKeys]filteredArrayUsingPredicate:predicate];
NSLog(@"filtered keys are %@",filteredKeys);

filteredDictionaryValues =[myDictionary dictionaryWithValuesForKeys:filteredKeys];
NSLog(@"filteredDicValues are %@",filteredDictionaryValues);




[self.SerchTable reloadData];

}

1 个答案:

答案 0 :(得分:0)

当您调用[filteredDictionaryValues valueForKey:[filteredDictionaryValues.allKeys objectAtIndex:indexPath.row]]时,返回的值是带有1个字符串对象(NSArray *array = [filteredDictionaryValues valueForKey:[filteredDictionaryValues.allKeys objectAtIndex:indexPath.row]]; NSString *string = [array firstObject];)的NSArray。如果可以的话,你应该改变填充字典的方式(而不是只有1个对象的数组对象)。如果没有,只需使用返回数组中的firstObject。