NSPredicate master data with SQLITE storage

This code returns 0 objects, which is incorrect. However, when a predicate is deleted, the select query returns all objects.

NSError *error = nil;

NSEntityDescription *entityDescription = [NSEntityDescription                                              entityForName:@"Person"  inManagedObjectContext:[self managedObjectContext]];

NSPredicate * pr = [NSPredicate predicateWithFormat:@"%K beginswith '%@' ",
                    @"FullName", searchText];

//NSPredicate * pr = [NSPredicate predicateWithFormat:@"PersonID == %@", searchText]; Works fine


NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:entityDescription];
 [request setPredicate:pr];
NSArray * arr = [[self managedObjectContext] executeFetchRequest:request error:&error];

The FullName attribute contains Unicode data (Arabic).

Any help is appreciated.

+3
source share
1 answer

Try:

NSPredicate * pr = [NSPredicate predicateWithFormat:@"FullName beginswith %@", searchText];
+7
source

Source: https://habr.com/ru/post/1791036/


All Articles