iEngineer
iEngineer

Reputation: 1319

Get NSManagedObject from NSSet

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.

Upvotes: 0

Views: 294

Answers (1)

Lennart
Lennart

Reputation: 61

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.

Upvotes: 1

Related Questions