Given an NSArrayController
"objController" which is bound to the moc in IB, shouldn't the following work? And given that it doesn't seem to work, how do I go about retrieving an entity's name from my NSArrayController
?
for (NSManagedObject *thisObj in [objController arrangedObjects])
{
NSEntityDescription *description = [thisObj entity];
NSString *entityName = [description name];
// do something with entityName...
NSString *entityAttributeValue = [thisObj valueForKey:@"attributeKey"];
// do something with entityAttributeValue...
}
The "objController" is IBOutlet-ed and set to "Entity Name" Mode, with the entity name set to an entity defined in the model. This entity does have child entities (and thus the reason I would like to access its description name, since the NSArrayController
could store many different child entity types), but the presence of child entities doesn't seem to make a difference anyway.
... in the debugger, it looks like "description" is a valid NSEntityDescription
object, but "entityName" gets set to a _PFEncodedString
object, with no content. However, "entityAttributeValue" is just fine, populated with the correct value stored in Core Data.
One way around this, I suppose, would be to custom-class all my CD entities, then use -isKindOfClass
to get the information I need.
Any ideas?
_PFEncodedString
is a (private) concrete subclass of NSString
and can therefore be used as any other NSString
.