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

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

问题描述

我有以下情况:
我有一个 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??

我认为错误就在这附近。

I suppose the error is somewhere around here.

- (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:count 在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.

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

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