Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

xcode navigation search bar

Hi Guys

quick question

i have a table being populated and i am trying to implement the search, it does filter, but always returns zero rows, so the problem lies where its trying to company. there is a part i am getting wrong

the exact problem i think is this part for (NSDictionary *dictionary in appDelegate.tbldrinks) //listOfItems) { NSArray *array = [dictionary objectForKey:@"name"]; [searchArray addObjectsFromArray:array]; }

maybe i am not getting what the objectForKey"@ is suppose to be... is it the key of the field i am comparing? ie: table column 0,1 are name, type, table name drink i tried @"drink" i tried @"name" all fail error: 2011-05-20 14:50:07.750 example[16197:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[drink objectForKey:]: unrecognized selector sent to instance 0x4e14290'

full code:

(void) searchTableView {

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

exampleAppDelegate *appDelegate = (exampleAppDelegate *)[[UIApplication sharedApplication] delegate];

for (NSDictionary *dictionary in appDelegate.tbldrinks) //listOfItems) { NSArray *array = [dictionary objectForKey:@"name"]; [searchArray addObjectsFromArray:array]; }

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

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

}

[searchArray release]; searchArray = nil; }

Posted on May 20, 2011 11:56 AM

Reply

There are no replies.

xcode navigation search bar

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.