---
title: "insertNewObject(forEntityName:into:)"
framework: coredata
role: symbol
role_heading: Type Method
path: "coredata/nsentitydescription/insertnewobject(forentityname:into:)"
---

# insertNewObject(forEntityName:into:)

Creates, configures, and returns an instance of the class for the entity with a given name.

## Declaration

```swift
class func insertNewObject(forEntityName entityName: String, into context: NSManagedObjectContext) -> NSManagedObject
```

## Parameters

- `entityName`: The name of an entity.
- `context`: The managed object context to use.

## Return Value

Return Value A new, autoreleased, fully configured instance of the class for the entity named entityName. The instance has its entity description set and is inserted it into context.

## Discussion

Discussion This method makes it easy for you to create instances of a given entity without worrying about the details of managed object creation. The method is conceptually similar to the following code example. NSManagedObjectModel *managedObjectModel =         [[context persistentStoreCoordinator] managedObjectModel]; NSEntityDescription *entity =         [[managedObjectModel entitiesByName] objectForKey:entityName]; NSManagedObject *newObject = [[NSManagedObject alloc]             initWithEntity:entity insertIntoManagedObjectContext:context]; return newObject;

## See Also

### Related Documentation

- [init(entity:insertInto:)](coredata/nsmanagedobject/init(entity:insertinto:).md)
