P
P
PKochubey2014-06-02 14:23:50
Objective-C
PKochubey, 2014-06-02 14:23:50

[Core Data] NSPredicate + LIKE - why is it always 0 in the console?

I make a request from the console to the sqlite database:
SELECT * FROM book WHERE title LIKE '%новые%';
in response to the request, I get the expected output.
I'm trying to set the same thing in iOS via NSPredicate:

NSFetchRequest *fetchRequest = ];
        
[fetchRequest setEntity:[NSEntityDescription entityForName:@"book" inManagedObjectContext:app.managedObjectContext]];
[fetchRequest setReturnsDistinctResults:YES];
[fetchRequest setPredicate:predicate];

NSArray *finding = [app.managedObjectContext executeFetchRequest:fetchRequest error:nil];
NSLog(@"%i", [finding count]);

I always get 0 in the console. I did without NSString stringWithFormat, %% and even quotes, as shown in the documentation, but I still get nothing. If you do not use NSPredicate, then all records are selected accordingly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Morozov, 2014-06-02
@PKochubey

https://developer.apple.com/library/ios/documentat...
LIKE
The left hand expression equals the right-hand expression: ? and * are allowed as wildcard characters, where ? matches 1 character and * matches 0 or more characters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question