How to access the attributes of a Core Data object in code?

I have the following bit of code in one of my methods:

...
NSNumber *selectedRecordID = [NSNumber numberWithInt:ABRecordGetRecordID(person)];
for (NSManagedObject *managedObject in fetchedResultsController.fetchedObjects) {
    if (selectedRecordID == managedObject.contactID) { // this line generates a compiler error
     // do some stuff
     }

The specified line generates a compiler error "Request for" contactID "in something that is not a structure or union." However, the "contactID" is an attribute of the objects received by the recipient of the results, and is present in the @property ads generated by Core Data.

What am I missing here? Thanks in advance for any help you can give.

+3
source share
2 answers

'contactID' NSManagedObject, . , , :

for (MyEntity *managedObject in fetchedResultsController.fetchedObjects) {
if (selectedRecordID == managedObject.contactID) { 
 }
+2

KVC :

[managedObject valueForKey:@"contactID"];
+4

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


All Articles