3 ms·
You can do a filter method in Obj-C with blocks, or even plain C with function pointers.
by pavlov 9y ago
You can do a filter method in Obj-C with blocks, or even plain C with function pointers.
- melling 9y agoSomething like this? https://stackoverflow.com/questions/9558335/filter-an-nsarray-which-contains-custom-objects https://stackoverflow.com/questions/9558335/filter-an-nsarra... Food food1 = [Food alloc]initWithName:@"samsar" andId:@"1"]; Food food2 = [Food alloc] initWithName:@"rusaramar" andId:@"2"]; NSSarray array = [NSArray arrayWithObjects:food1, food2, nil]; [array filterUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary bindings) { return [evaluatedObject.foodName hasPrefix:searchBar.text]; }];