I have a view controller that can fetch many different types of entities from my MOC. How can I tell what the entity is for an object of the type NSManagedObject?
NSManagedObject *object = (NSManagedObject *)[locations objectAtIndex:indexPath.row]; NSEntityDescription *entityDescr = [object entity]; NSLog(@"%@", [entityDescr name]);This throws an error... *** -[NSKnownKeysDictionary1 entity]: unrecognized selector sent to instance 0x3e39cc0
E-Madd
2010-04-09 03:36:44
+2
A:
[managedObject entity]
will give you an NSEntityDescription
. From there you can send it -name
to get the entity's name that's a bit more user-friendly.
Giao
2010-04-09 03:32:09
NSManagedObject *object = (NSManagedObject *)[locations objectAtIndex:indexPath.row];NSEntityDescription *entityDescr = [object entity];NSLog(@"%@", [entityDescr name]);throws and error... *** -[NSKnownKeysDictionary1 entity]: unrecognized selector sent to instance 0x3e39cc0
E-Madd
2010-04-09 03:37:43
That's because the returned value from `[locations objectAtIndex:indexPath.row]` isn't an NSManagedObject. I bet if you NSLog that object, it won't show up as an NSManagedObject.
Giao
2010-04-09 03:44:54