Query query of the main database with an array

I am trying to set a query query with a predicate to retrieve records in the store whose identifier attribute corresponds to an array of identifiers specified in the predicate, for example.

NSString *predicateString = [NSString stringWithFormat:@"identifier IN %@", employeeIDsArray];

EmployIDsArray contains several NSNumber objects that correspond to identifiers in the repository. However, I get the error "Unable to parse format string." This type of predicate works if it is used to filter an array, but, as mentioned, is not executed to fetch kernel data. How do I set a predicate?

+3
source share
2 answers

NSPredicate , NSString. String .

:

NSPredicate * predicate = [NSPredicate predicateWithFormat:@"identifier IN %@", employeeIDsArray];
[fetchRequest setPredicate:predicate];

. .

+10

stringWithFormat:, description (, ), %@.

, . , ; . , stringWithFormat: -pass predicateWithFormat: .

+4

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


All Articles