<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSObjectController/newObject()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObjectController(im)newObject"
  },
  "title" : "newObject()"
}
-->

# newObject()

Creates and returns a new object of the appropriate class.

```
func newObject() -> Any
```

## Return Value

A new object of the appropriate class. The returned object is implicitly retained, the sender is responsible for releasing it (with either release or autorelease).

## Discussion

If an entity name is set (see [`entityName`](/documentation/AppKit/NSObjectController/entityName)), the object created is an instance of the class specified for that entity (and the object is inserted into the receiver’s managed object context). Otherwise the object created is an instance of the class returned by [`objectClass`](/documentation/AppKit/NSObjectController/objectClass).

This method is called when adding and inserting objects if [`automaticallyPreparesContent`](/documentation/AppKit/NSObjectController/automaticallyPreparesContent) is <doc://com.apple.documentation/documentation/Swift/true>.

The default implementation assumes the class returned by [`objectClass`](/documentation/AppKit/NSObjectController/objectClass) has a standard  `init` method without arguments. If the object class being controlled is `NSManagedObject` (or a subclass thereof) its designated initializer (<doc://com.apple.documentation/documentation/CoreData/NSManagedObject/init(entity:insertInto:)>) is called instead, using the entity and managed object context specified for the receiver.

## See Also

[`objectClass`](/documentation/AppKit/NSObjectController/objectClass)

The object class to use when creating new objects.

[`entityName`](/documentation/AppKit/NSObjectController/entityName)

The entity name used by the receiver to create new objects.



---

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)