How would I create an NSPredicate to filter by entity of class Contact?
The solution to NSPredicate check for kind of object class crashes:
[NSPredicate predicateWithFormat:@"person.class == %@", [Contact class]];
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'keypath person.class not found in entity <NSSQLEntity User id=12>'
I have the Core Data entities User (app user) & Contact (address book contact), both children of Person (abstract entity). Person has many identities, which can be emails, phones, or usernames.
To create a text-message-like typeahead, I want to create an NSFetchRequest for Identity entities where person is of class Contact.
You are perhaps mixing up a few things. The answer you indicate is about a predicate to filter an array of UIViews. A predicate in core data works in a slightly different way.
To achieve your desired result, simply set the entity of your fetch request to @"Contact".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With