views:

101

answers:

2

Hy Everybody,

i have the following situation. I have an NSMuttableArray filled with an xml file which I want to search. When I enter something in the searchfield 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;
}

Thanks for every Help und Ideas

+1  A: 

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.

Jesse Naugher
searchList was just a typos
zim
now that I changed my NSArray --> NSString and addObjectsFromArray --> addObject the Search filter works perfectly but when I empty the search field it craches again with "NSCFString count"
zim
A: 

Hello, I am doing the same exact thing using an rss feed, I tried making the changes u made, but it my code still crashes:

  • (void) searchTableView {

    NSString *searchText = searchBar.text; NSMutableArray *searchArray = [[NSMutableArray alloc] init];

    for (NSDictionary *dictionary in stories) { NSString *array = [dictionary objectForKey:@"title"]; [searchArray addObject:array]; }

    for (NSString *sTemp in searchArray) { NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch];

    if (titleResultsRange.length > 0)
    [storiesCopy addObject:sTemp];
    

    }

    [searchArray release]; searchArray = nil; }

Ibraam