zim zim - 8 months ago 55
Objective-C Question

NSCFString countByEnumeratingWithState:objects:count: ERROR while searching NSMutableArray

I have the following situation where
I have an

filled with an
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;


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

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.