Type Method

entityForName:inManagedObjectContext:

Returns the entity with the specified name from the managed object model associated with the specified managed object context’s persistent store coordinator.

Declaration

+ (NSEntityDescription *)entityForName:(NSString *)entityName inManagedObjectContext:(NSManagedObjectContext *)context;

Parameters

entityName

The name of an entity.

context

The managed object context to use. Must not be nil.

Return Value

The entity with the specified name from the managed object model associated with context’s persistent store coordinator.

Discussion

Raises NSInternalInconsistencyException if context is nil.

This method is functionally equivalent to the following code example.

NSManagedObjectModel *managedObjectModel = [[context persistentStoreCoordinator] managedObjectModel];
NSEntityDescription *entity = [[managedObjectModel entitiesByName] objectForKey:entityName];
return entity;

See Also