iphone – NSCFString countByEnumeratingWithState:objects:count:搜索NSMutableArray时出错

我有以下情况
我有一个NSMutableArray填充了我想要搜索的xml文件.
当我在搜索字段中输入内容时,出现此错误:

-[NSCFString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x5b388b0

它意味着什么,我该如何解决?

我想错误就在这附近.

- (void)searchTableView{

 searchedList = [[NSMutableArray alloc] init];
 NSLog(@"new list %@", searchedList);
 NSString *searchText = searchBar.text;
 NSMutableArray *searchArray = [[NSMutableArray alloc] init];

 for (NSDictionary *dictionary in list) {
    NSArray *array = [dictionary objectForKey:@"TITLE"];
   [searchArray addObjectsFromArray:array];
 }

 for (NSString *TempArray in searchArray) {
  NSRange titleResults = [TempArray rangeOfString:searchText options:NSCaseInsensitiveSearch];
  if (titleResults.length > 0) 
  [searchedList addObject:TempArray];
 }
 [searchArray release];
 searchArray = nil;
}
它意味着您正在调用为NSArray设计的方法(countByEnumeratingWithState:objects:指向NSString.

我不知道这段代码是否是您的代码复制/粘贴,但如果是这样,在您使用[searchList addObject:TempArray]的末尾,您没有名为searchList的对象.

此外,处理您的命名约定.重要时刻.

https://stackoverflow.com/questions/3659958/nscfstring-countbyenumeratingwithstateobjectscount-error-while-searching-nsmu

转载注明原文:iphone – NSCFString countByEnumeratingWithState:objects:count:搜索NSMutableArray时出错