user134611
user134611

Reputation: 776

Search string in NSMutableArray for showing in Table

Okay, I have an Book Object Class. That has Book.name and Book.id as extensions. Book.name being NSString. Which is what should be searchable and listed in UITableView.

NSMutableArray *matchingSymptomsArray = [[NSMutableArray alloc] initWithCapacity:50];

for(NSMutableArray *letterArray in DataArray){
        for(Book *bk in letterArray){ //Heres the ERROR
            NSLog(@"Uptil NEW");
            if([bk matchesSearchString:searchString]){
                        //I couldnt reach here, according to debugging and Logs//
                [matchingSymptomsArray addObject:bk];
            }
        }
    }

DataArray is where all the Books are held.. more than a hundred. Its the main datasource for the UITableView. I'm trying to search and match each letter of the string with the Book.name, but even before I can begin, I cant do the for(Book *bk in LetterArray) //producing the error..

What seems to be the problem?

This is the error in console **** -[Book countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x55c110 2009-09-29 06:17:41.073 Smart Diagnosis[3897:20b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[Book countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x55c110'

Any work arounds??

thanks for your help :)

Upvotes: 0

Views: 2477

Answers (2)

ennuikiller
ennuikiller

Reputation: 46965

Did you check that letterArray isnt nil or empty?

Upvotes: 0

ennuikiller
ennuikiller

Reputation: 46965

Try this:

for (id bk in letterArray) { }

Did you check that letterArray isnt nil or empty?

Upvotes: 1

Related Questions