Hi,
Let say the data entities are: Bookshop <--->> Books
How do I fetch all books belonging to a specific book shop that contain "cloud" in the name for example? The following method feel clunky.
Bookshop *bookshop = (Bookshop *) nsManagedObjectFromOwner;
NSString *searchTerm = @"cloud";
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Books"
inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"ANY bookshop.Name == '%@' && Name contain[cd] '%@'",
bookshop.Name, searchTerm];
[fetchRequest setPredicate: predicate];
How could I improve this code to handle if there are 2 book shops with very similar names? And maybe also performance improvement for fetching as the UITableView should update as the user type in book name.