0

This answer suggests that to get an object from the objected, you use a method such as this:

-(NSManagedObject *)objectRegisteredForID:(NSManagedObjectID *)objectID

or

-(NSManagedObject *)objectWithID:(NSManagedObjectID *)objectID

This may be a dumb question but how do you call these methods? With the MOC, managed object and other objects involved, am finding this very confusing and not succeeding in calling either method.

This is giving a 'use of undeclared identifier' error, for example:

NSManagedObject *object = objectRegisteredForID:self.moID;

Thanks for any clarification.

Community
  • 1
  • 1
  • Both of these methods, and the third method mentioned in the link, are all declared in NSManagedObjectContext. Hence you would call these methods on NSManagedObjectContext. If using private conncurrency be sure you are in the context's block – feliun Nov 04 '15 at 14:43
  • https://www.objc.io/issues/4-core-data/core-data-overview/ – Kemal Can Kaynak Nov 04 '15 at 14:43

1 Answers1

0

Yes, both are methods of the NSManagedObjectContext therefore you need to call this method on an NSManagedObjectContext instance where this object is in.

See also https://developer.apple.com/library/mac/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObjectContext_Class/index.html#//apple_ref/occ/instm/NSManagedObjectContext/objectWithID:

Sebastian Wramba
  • 10,087
  • 8
  • 41
  • 58
  • NSManagedObject *object = [self.managedObjectContext objectRegisteredForID:_moID]; is working –  Nov 04 '15 at 14:51