<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSEntityDescription/insertNewObject(forEntityName:into:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSEntityDescription(cm)insertNewObjectForEntityForName:inManagedObjectContext:"
  },
  "title" : "insertNewObject(forEntityName:into:)"
}
-->

# insertNewObject(forEntityName:into:)

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

```
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

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

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.

```objc
NSManagedObjectModel *managedObjectModel =
        [[context persistentStoreCoordinator] managedObjectModel];
NSEntityDescription *entity =
        [[managedObjectModel entitiesByName] objectForKey:entityName];
NSManagedObject *newObject = [[NSManagedObject alloc]
            initWithEntity:entity insertIntoManagedObjectContext:context];
return newObject;
```

## See Also

[`init(entity:insertInto:)`](/documentation/CoreData/NSManagedObject/init(entity:insertInto:))

Initializes a managed object from an entity description and inserts it into the specified managed object context.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)