Frage

As CoreData length is not supported and CoreData translates the predicate name.length > 1 to sqlite in name > 1... While it should be length(name) > 1.

We can use this one: [NSPredicate predicateWithFormat:@"NOT name MATCHES '^\s*$'"];

But regular expression will have a higher computation cost (takes longer than to evaluate a regex than simple equality).

SO how i have to do fetch.Any best idea ?

War es hilfreich?

Lösung

Please go through CoreData predicate: string property length?

or you can do like this

NSString *attributeName = @"name";
NSString *attributeValue = [NSString stringWithFormat:@".{%d}", 5];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K MATCHES %@", attributeName, attributeValue];

Reference - NSPredicate for an NSManagedObject's string attribute's length

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top