A controller that can manage an object's properties referenced by key-value paths.


@interface NSObjectController : NSController


NSObjectController is a Cocoa bindings–compatible controller class. Properties of the content object of instances of this class can be bound to user interface elements to access and modify their values.

By default, the content of an NSObjectController instance is an NSMutableDictionary object. This allows a single NSObjectController instance to be used to manage many different properties referenced by key-value paths. The default content object class can be changed by calling objectClass, which subclasses must override. Your application should use a custom data class that is key-value compliant whenever possible.

Object Controllers, Entity Mode, and Lazy Fetching

NSObjectController and its subclasses, when in entity mode, can now fetch lazily. With lazy fetching enabled using the property usesLazyFetching, the controller will try to fetch only a small amount of data from available persistent stores. This can provide a significant improvement in memory use when a large amount of content is stored on disk but just a subset of that data is required in memory.

When set to use lazy fetching, a controller will fetch objects in batches. You can change the default batch size for your application by setting a value for the the user default "". If you have table views bound to an array controller set to use lazy fetching, the size of the controller's batch size will grow as the table views' visible row count grows.

Add, Insert, and Remove operations on controllers that use lazy fetching behave similarly to the same operations on a regular controller. The difference is that it is faster to sort an array controller using lazy fetching if:

  • All of the keys in the sortDescriptors array are modeled, non transient properties.

  • All of the selectors in the sortDescriptors array are compare: or caseInsensitiveCompare:.

  • There are no changes in the controller's managed object context


Initializing an object controller

- initWithContent:

Initializes and returns an NSObjectController object with the given content.

Managing content


The receiver’s content object.


A Boolean that shows whether the receiver automatically creates and inserts new content objects automatically when loading from a nib file.

- prepareContent

Typically overridden by subclasses that require additional control over the creation of new objects.

Setting the content class


The object class to use when creating new objects.

Managing objects

- newObject

Creates and returns a new object of the appropriate class.

- addObject:

Sets the receiver’s content object.

- removeObject:

Removes a given object from the receiver’s content.

- add:

Creates a new object and sets it as the receiver’s content object.


A Boolean value that indicates whether an object can be added to the receiver using add:.

- remove:

Removes the receiver’s content object.


A Boolean value that indicates whether an object can be removed from the receiver.

Managing editing


A Boolean that indicates whether the receiver allows adding and removing objects.

Core Data support


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

- fetch:

Causes the receiver to fetch the data objects specified by the entity name and fetch predicate.


A Boolean that indicates whether the receiver uses lazy fetching.

- defaultFetchRequest

Returns the default fetch request used by the receiver.


The receiver’s fetch predicate.


The receiver’s managed object context.

- fetchWithRequest:merge:error:

Subclasses should override this method to customize a fetch request, for example to specify fetch limits.

Obtaining selections


An array of all objects to be affected by editing.


A proxy object representing the receiver’s selection.

Validating user interface items

- validateUserInterfaceItem:

Returns whether the receiver can handle the action method for a user interface item.



Inherits From

See Also

Core Controllers


An abstract class that implements the NSEditor and NSEditorRegistration informal protocols required for controller classes.