NSCFString countByEnumatingWithState:objects:count: 搜索 NSMutableArray 时出错 [英] NSCFString countByEnumeratingWithState:objects:count: ERROR while searching NSMutableArray

查看:27
本文介绍了NSCFString countByEnumatingWithState:objects:count: 搜索 NSMutableArray 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have the following situation where I have an NSMutableArray filled with an xml file which I want to search. When I enter something in the search field I get this Error:

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

这是什么意思,我该如何解决?

What does it means and how can I fix it??

我想错误就在这里.

- (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 设计的方法 (countByEnumatingWithState:objects:count on an NSString.

it means you are calling a method designed for an NSArray (countByEnumeratingWithState:objects:count on a NSString.

我不知道此代码是否是从您的复制/粘贴,但如果是,在您使用 [searchList addObject:TempArray] 的最后,您没有名为 searchList.

I don't know ifthis code is copy/paste from yours, but if so, at the end where you use [searchList addObject:TempArray] you don't have an object named searchList.

此外,请注意您的命名约定.好久不见.

Also, work on your naming conventions. big time.

这篇关于NSCFString countByEnumatingWithState:objects:count: 搜索 NSMutableArray 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆