Question

I have NSSet containing NSManagedObjects from NSManagedObjectContextDidSaveNotification notification.
The problem is that: I want to get the type of NSManagedObject in NSSet.
For example, is it Album, User or any other NSManagedObject.

Was it helpful?

Solution

Say you have a managed object called entity, then use the following code to retrieve the name of the managed object:

NSManagedObjectID *objectID = [entity objectID];
NSEntityDescription *entityDescription = [objectID entity];
NSString *name = [entityDescription name];

For clarity I've declared variables on each line, but of course you could also write [[[entity objectID] entity] name]

I hope this is what you're looking for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top