Contents

newObject()

Creates and returns a new object of the appropriate class.

Declaration

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), 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.

This method is called when adding and inserting objects if automaticallyPreparesContent is true.

The default implementation assumes the class returned by objectClass has a standard init method without arguments. If the object class being controlled is NSManagedObject (or a subclass thereof) its designated initializer (init(entity:insertInto:)) is called instead, using the entity and managed object context specified for the receiver.

See Also

Related Documentation

Managing objects