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

# NSCell

A mechanism for displaying text or images in a view object without the overhead of a full [`NSView`](/documentation/AppKit/NSView) subclass.

```
@MainActor class NSCell
```

## Overview

Cells are used by most of the [`NSControl`](/documentation/AppKit/NSControl) classes to implement their internal workings.

### Designated Initializers

When subclassing `NSCell` you must implement all of the designated initializers. Those methods include [`init()`](/documentation/AppKit/NSCell/init()), [`init(coder:)`](/documentation/AppKit/NSCell/init(coder:)), [`init(textCell:)`](/documentation/AppKit/NSCell/init(textCell:)), and [`init(imageCell:)`](/documentation/AppKit/NSCell/init(imageCell:)).

## Topics

### Initializing a Cell

[`-  initImageCell:`](/documentation/AppKit/NSCell/init(imageCell:))

Returns an `NSCell` object initialized with the specified image and set to have the cell’s default menu.

[`-  initTextCell:`](/documentation/AppKit/NSCell/init(textCell:))

Returns an NSCell object initialized with the specified string and set to have the cell’s default menu.

### Managing Cell Values

[`objectValue`](/documentation/AppKit/NSCell/objectValue)

The cell’s value as an Objective-C object.

[`hasValidObjectValue`](/documentation/AppKit/NSCell/hasValidObjectValue)

A Boolean value that indicates whether the cell has a valid object value.

[`intValue`](/documentation/AppKit/NSCell/intValue)

The cell’s value as an integer.

[`integerValue`](/documentation/AppKit/NSCell/integerValue)

The cell’s value as an integer value.

[`stringValue`](/documentation/AppKit/NSCell/stringValue)

The cell’s value as a string.

[`doubleValue`](/documentation/AppKit/NSCell/doubleValue)

The cell’s value as a double-precision floating-point number.

[`floatValue`](/documentation/AppKit/NSCell/floatValue)

The cell’s value as a single-precision floating-point number.

### Managing Cell Attributes

[`-  setCellAttribute:to:`](/documentation/AppKit/NSCell/setCellAttribute(_:to:))

Sets the value for the specified cell attribute.

[`-  cellAttribute:`](/documentation/AppKit/NSCell/cellAttribute(_:))

Returns the value for the specified cell attribute.

[`type`](/documentation/AppKit/NSCell/type)

The type of the cell.

[`enabled`](/documentation/AppKit/NSCell/isEnabled)

A Boolean value indicating whether the cell is currently enabled.

[`allowsUndo`](/documentation/AppKit/NSCell/allowsUndo)

A Boolean value indicating whether the cell assumes responsibility for undo operations.

### Managing Display Attributes

[`bezeled`](/documentation/AppKit/NSCell/isBezeled)

A Boolean value indicating whether the cell has a bezeled border.

[`bordered`](/documentation/AppKit/NSCell/isBordered)

A Boolean value indicating whether the cell draws itself outlined with a plain border.

[`opaque`](/documentation/AppKit/NSCell/isOpaque)

A Boolean value indicating whether the cell is completely opaque.

[`controlTint`](/documentation/AppKit/NSCell/controlTint)

The cell’s control tint.

[`backgroundStyle`](/documentation/AppKit/NSCell/backgroundStyle)

The cell’s background style.

[`interiorBackgroundStyle`](/documentation/AppKit/NSCell/interiorBackgroundStyle)

The cell’s interior background style.

[`BackgroundStyle`](/documentation/AppKit/NSView/BackgroundStyle)

Background styles to apply to a view’s cell.

### Managing Cell State

[`allowsMixedState`](/documentation/AppKit/NSCell/allowsMixedState)

A Boolean value indicating whether the cell supports three states instead of two.

[`nextState`](/documentation/AppKit/NSCell/nextState)

The cell’s next state.

[`-  setNextState`](/documentation/AppKit/NSCell/setNextState())

Changes cell’s state to the next value in the sequence.

[`state`](/documentation/AppKit/NSCell/state)

The cell’s current state.

[`StateValue`](/documentation/AppKit/NSControl/StateValue)

A constant that indicates whether a control is on, off, or in a mixed state.

### Modifying Textual Attributes

[`editable`](/documentation/AppKit/NSCell/isEditable)

A Boolean value indicating whether the cell is editable.

[`selectable`](/documentation/AppKit/NSCell/isSelectable)

A Boolean value indicating whether the cell’s text can be selected.

[`scrollable`](/documentation/AppKit/NSCell/isScrollable)

A Boolean value indicating whether excess text scrolls past the cell’s bounds.

[`alignment`](/documentation/AppKit/NSCell/alignment)

The alignment of the cell’s text.

[`font`](/documentation/AppKit/NSCell/font)

The font that the cell uses to display text.

[`lineBreakMode`](/documentation/AppKit/NSCell/lineBreakMode)

The line break mode to use when drawing text in the cell.

[`truncatesLastVisibleLine`](/documentation/AppKit/NSCell/truncatesLastVisibleLine)

A Boolean value indicating whether the cell truncates text that does not fit within the cell’s bounds.

[`wraps`](/documentation/AppKit/NSCell/wraps)

A Boolean value indicating whether the cell wraps text whose length that exceeds the cell’s frame.

[`baseWritingDirection`](/documentation/AppKit/NSCell/baseWritingDirection)

The initial writing direction used to determine the actual writing direction for text.

[`attributedStringValue`](/documentation/AppKit/NSCell/attributedStringValue)

The cell’s value as an attributed string.

[`allowsEditingTextAttributes`](/documentation/AppKit/NSCell/allowsEditingTextAttributes)

A Boolean value indicating whether the cell allows the editing of its content’s text attributes by the user.

[`importsGraphics`](/documentation/AppKit/NSCell/importsGraphics)

A Boolean value indicating whether the cell supports the importation of images into its text.

[`-  setUpFieldEditorAttributes:`](/documentation/AppKit/NSCell/setUpFieldEditorAttributes(_:))

Configures the textual and background attributes of the receiver’s field editor.

[`title`](/documentation/AppKit/NSCell/title)

The cell’s title text.

### Managing the Target and Action

[`action`](/documentation/AppKit/NSCell/action)

The action performed by the cell.

[`target`](/documentation/AppKit/NSCell/target)

The object that receives the cell’s action messages.

[`continuous`](/documentation/AppKit/NSCell/isContinuous)

A Boolean value indicating whether the cell sends its action message continuously during mouse tracking.

[`-  sendActionOn:`](/documentation/AppKit/NSCell/sendAction(on:))

Sets the conditions on which the receiver sends action messages to its target.

### Managing the Image

[`image`](/documentation/AppKit/NSCell/image)

The image displayed by the cell, if any.

### Managing the Tag

[`tag`](/documentation/AppKit/NSCell/tag)

A tag for identifying the cell.

### Formatting and Validating Data

[`formatter`](/documentation/AppKit/NSCell/formatter)

The cell’s formatter object.

### Managing Menus

[`defaultMenu`](/documentation/AppKit/NSCell/defaultMenu)

Returns the default menu for instances of the cell.

[`menu`](/documentation/AppKit/NSCell/menu)

The cell’s contextual menu.

[`-  menuForEvent:inRect:ofView:`](/documentation/AppKit/NSCell/menu(for:in:of:))

Returns the menu associated with the cell and related to the specified event and frame.

### Comparing Cells

[`-  compare:`](/documentation/AppKit/NSCell/compare(_:))

Compares the string values of the receiver another cell, disregarding case.

### Respond to Keyboard Events

[`acceptsFirstResponder`](/documentation/AppKit/NSCell/acceptsFirstResponder)

A Boolean value indicating whether the cell accepts first responder status.

[`showsFirstResponder`](/documentation/AppKit/NSCell/showsFirstResponder)

A Boolean value indicating whether the cell provides a visual indication that it is the first responder.

[`refusesFirstResponder`](/documentation/AppKit/NSCell/refusesFirstResponder)

A Boolean value indicating whether the cell refuses the first responder status.

[`-  performClick:`](/documentation/AppKit/NSCell/performClick(_:))

Simulates a single mouse click on the receiver.

### Deriving Values

[`-  takeObjectValueFrom:`](/documentation/AppKit/NSCell/takeObjectValueFrom(_:))

Sets the value of the receiver’s cell to the object value obtained from the specified object.

[`-  takeIntegerValueFrom:`](/documentation/AppKit/NSCell/takeIntegerValueFrom(_:))

Sets the value of the receiver’s cell to an integer value obtained from the specified object.

[`-  takeIntValueFrom:`](/documentation/AppKit/NSCell/takeIntValueFrom(_:))

Sets the value of the receiver’s cell to an integer value obtained from the specified object.

[`-  takeStringValueFrom:`](/documentation/AppKit/NSCell/takeStringValueFrom(_:))

Sets the value of the receiver’s cell to the string value obtained from the specified object.

[`-  takeDoubleValueFrom:`](/documentation/AppKit/NSCell/takeDoubleValueFrom(_:))

Sets the value of the receiver’s cell to a double-precision floating-point value obtained from the specified object.

[`-  takeFloatValueFrom:`](/documentation/AppKit/NSCell/takeFloatValueFrom(_:))

Sets the value of the receiver’s cell to a single-precision floating-point value obtained from the specified object.

### Representing an Object

[`representedObject`](/documentation/AppKit/NSCell/representedObject)

The object represented by the cell.

### Tracking the Mouse

[`-  trackMouse:inRect:ofView:untilMouseUp:`](/documentation/AppKit/NSCell/trackMouse(with:in:of:untilMouseUp:))

Initiates the mouse tracking behavior in a cell.

[`-  startTrackingAt:inView:`](/documentation/AppKit/NSCell/startTracking(at:in:))

Begins tracking mouse events within the receiver.

[`-  continueTracking:at:inView:`](/documentation/AppKit/NSCell/continueTracking(last:current:in:))

Returns a Boolean value that indicates whether mouse tracking should continue in the receiving cell.

[`-  stopTracking:at:inView:mouseIsUp:`](/documentation/AppKit/NSCell/stopTracking(last:current:in:mouseIsUp:))

Stops tracking mouse events within the receiver.

[`mouseDownFlags`](/documentation/AppKit/NSCell/mouseDownFlags)

The modifier flags for the last (left) mouse-down event.

[`prefersTrackingUntilMouseUp`](/documentation/AppKit/NSCell/prefersTrackingUntilMouseUp)

Returns a Boolean value that indicates whether tracking stops when the cursor leaves the cell.

[`-  getPeriodicDelay:interval:`](/documentation/AppKit/NSCell/getPeriodicDelay(_:interval:))

Returns the initial delay and repeat values for continuous sending of action messages to target objects.

### Hit Testing

[`-  hitTestForEvent:inRect:ofView:`](/documentation/AppKit/NSCell/hitTest(for:in:of:))

Returns hit testing information for the receiver.

### Managing the Cursor

[`-  resetCursorRect:inView:`](/documentation/AppKit/NSCell/resetCursorRect(_:in:))

Sets the receiver to show the I-beam cursor while it tracks the mouse.

### Handling Keyboard Alternatives

[`keyEquivalent`](/documentation/AppKit/NSCell/keyEquivalent)

The key equivalent associated with clicking the cell.

### Dragging Cells

[`-  draggingImageComponentsWithFrame:inView:`](/documentation/AppKit/NSCell/draggingImageComponents(withFrame:in:))

Generates dragging image components with the specified frame in the view.

### Managing Focus Rings

[`-  drawFocusRingMaskWithFrame:inView:`](/documentation/AppKit/NSCell/drawFocusRingMask(withFrame:in:))

Draws the focus ring for the control.

[`-  focusRingMaskBoundsForFrame:inView:`](/documentation/AppKit/NSCell/focusRingMaskBounds(forFrame:in:))

Returns the bounds of the focus ring mask.

[`defaultFocusRingType`](/documentation/AppKit/NSCell/defaultFocusRingType)

Returns the default type of focus ring for the receiver.

[`focusRingType`](/documentation/AppKit/NSCell/focusRingType)

The type of focus ring to use with the associated view.

### Determining Cell Size

[`-  calcDrawInfo:`](/documentation/AppKit/NSCell/calcDrawInfo(_:))

Recalculates the cell geometry.

[`cellSize`](/documentation/AppKit/NSCell/cellSize)

The minimum size needed to display the cell.

[`-  cellSizeForBounds:`](/documentation/AppKit/NSCell/cellSize(forBounds:))

Returns the minimum size needed to display the receiver, constraining it to the specified rectangle.

[`-  drawingRectForBounds:`](/documentation/AppKit/NSCell/drawingRect(forBounds:))

Returns the rectangle within which the receiver draws itself

[`-  imageRectForBounds:`](/documentation/AppKit/NSCell/imageRect(forBounds:))

Returns the rectangle in which the receiver draws its image.

[`-  titleRectForBounds:`](/documentation/AppKit/NSCell/titleRect(forBounds:))

Returns the rectangle in which the receiver draws its title text.

[`controlSize`](/documentation/AppKit/NSCell/controlSize)

The size of the cell.

### Drawing and Highlighting

[`-  drawWithFrame:inView:`](/documentation/AppKit/NSCell/draw(withFrame:in:))

Draws the receiver’s border and then draws the interior of the cell.

[`-  highlightColorWithFrame:inView:`](/documentation/AppKit/NSCell/highlightColor(withFrame:in:))

Returns the color the receiver uses when drawing the selection highlight.

[`-  drawInteriorWithFrame:inView:`](/documentation/AppKit/NSCell/drawInterior(withFrame:in:))

Draws the interior portion of the receiver, which includes the image or text portion but does not include the border.

[`controlView`](/documentation/AppKit/NSCell/controlView)

The view associated with the cell.

[`-  highlight:withFrame:inView:`](/documentation/AppKit/NSCell/highlight(_:withFrame:in:))

Redraws the receiver with the specified highlight setting.

[`highlighted`](/documentation/AppKit/NSCell/isHighlighted)

A Boolean value indicating whether the cell has a highlighted appearance.

### Editing and Selecting Text

[`-  editWithFrame:inView:editor:delegate:event:`](/documentation/AppKit/NSCell/edit(withFrame:in:editor:delegate:event:))

Begins editing of the receiver’s text using the specified field editor.

[`-  selectWithFrame:inView:editor:delegate:start:length:`](/documentation/AppKit/NSCell/select(withFrame:in:editor:delegate:start:length:))

Selects the specified text range in the cell’s field editor.

[`sendsActionOnEndEditing`](/documentation/AppKit/NSCell/sendsActionOnEndEditing)

A Boolean value indicating whether the cell’s control object sends its action message when the user finishes editing the cell’s text.

[`-  endEditing:`](/documentation/AppKit/NSCell/endEditing(_:))

Ends the editing of text in the receiver using the specified field editor.

[`wantsNotificationForMarkedText`](/documentation/AppKit/NSCell/wantsNotificationForMarkedText)

A Boolean value indicating whether the cell’s field editor should post text change notifications.

[`-  fieldEditorForView:`](/documentation/AppKit/NSCell/fieldEditor(for:))

Returns a custom field editor for editing in the view.

[`usesSingleLineMode`](/documentation/AppKit/NSCell/usesSingleLineMode)

A Boolean value indicating whether the cell restricts layout and rendering of text to a single line.

### Managing Expansion Frames

[`-  expansionFrameWithFrame:inView:`](/documentation/AppKit/NSCell/expansionFrame(withFrame:in:))

Returns the expansion cell frame for the receiver.

[`-  drawWithExpansionFrame:inView:`](/documentation/AppKit/NSCell/draw(withExpansionFrame:in:))

Instructs the receiver to draw in an expansion frame.

### User Interface Layout Direction

[`userInterfaceLayoutDirection`](/documentation/AppKit/NSCell/userInterfaceLayoutDirection)

The layout direction of the user interface.

### Constants

[`CellType`](/documentation/AppKit/NSCell/CellType)

Constants for specifying how a cell represents its data (as text or as an image).

[`Attribute`](/documentation/AppKit/NSCell/Attribute)

Constants for specifying how a button behaves when pressed and how it displays its state.

[`ImagePosition`](/documentation/AppKit/NSControl/ImagePosition)

A constant for specifying the position of a button’s image relative to its title.

[`NSImageScaling`](/documentation/AppKit/NSImageScaling)

Constants that specify a cell’s image scaling behavior.

[`StateValue`](/documentation/AppKit/NSCell/StateValue)

Constants for specifying a cell’s state and are used mostly for buttons.

[`StyleMask`](/documentation/AppKit/NSCell/StyleMask)

Constants for specifying what happens when a button is pressed or is displaying its alternate state.

[`NSControlTint`](/documentation/AppKit/NSControlTint)

Constants for specifying a cell’s tint color.

[`ControlSize`](/documentation/AppKit/NSControl/ControlSize-swift.enum)

A constant for specifying a cell’s size.

[`HitResult`](/documentation/AppKit/NSCell/HitResult)

Constants used by the [`hitTest(for:in:of:)`](/documentation/AppKit/NSCell/hitTest(for:in:of:)) method to determine the effect of an event.

[`BackgroundStyle`](/documentation/AppKit/NSView/BackgroundStyle)

Background styles to apply to a view’s cell.

[Deprecated Scaling Constants](/documentation/AppKit/deprecated-scaling-constants)

These are deprecated scaling constants.

[Data Entry Types](/documentation/AppKit/data-entry-types)

These constants specify how a cell formats numeric data.

### Notifications

[`NSControlTintDidChangeNotification`](/documentation/AppKit/NSColor/currentControlTintDidChangeNotification)

Sent after the user changes control tint preference.

### Deprecated Methods

[`-  setEntryType:`](/documentation/AppKit/NSCell/setEntryType:)

Sets how numeric data is formatted in the receiver and places restrictions on acceptable input.

[`-  entryType`](/documentation/AppKit/NSCell/entryType)

Returns the type of data the user can type into the receiver.

[`-  isEntryAcceptable:`](/documentation/AppKit/NSCell/isEntryAcceptable:)

Returns whether a string representing a numeric or date value is formatted in a suitable way for the cell’s entry type.

[`-  setFloatingPointFormat:left:right:`](/documentation/AppKit/NSCell/setFloatingPointFormat:left:right:)

Sets the auto-ranging and floating point number format of the receiver’s cell.

[`-  setTitleWithMnemonic:`](/documentation/AppKit/NSCell/setTitleWithMnemonic:)

Sets the title of the receiver with one character in the string denoted as an access key.

[`-  mnemonic`](/documentation/AppKit/NSCell/mnemonic)

Returns the character in the receiver’s title that appears underlined for use as a mnemonic.

[`-  setMnemonicLocation:`](/documentation/AppKit/NSCell/setMnemonicLocation:)

Sets the character of the receiver’s title to be used as a mnemonic character.

[`-  mnemonicLocation`](/documentation/AppKit/NSCell/mnemonicLocation)

Returns the position of the underlined mnemonic character in the receiver’s title.

### Initializers

[`-  init`](/documentation/AppKit/NSCell/init())

[`-  initWithCoder:`](/documentation/AppKit/NSCell/init(coder:))

## Relationships

### Conforms To

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSUserInterfaceItemIdentification`](/documentation/AppKit/NSUserInterfaceItemIdentification)

[`NSAccessibilityElementProtocol`](/documentation/AppKit/NSAccessibilityElementProtocol)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSAccessibilityProtocol`](/documentation/AppKit/NSAccessibilityProtocol)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Sendable`](/documentation/Swift/Sendable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

### Inherited By

[`NSActionCell`](/documentation/AppKit/NSActionCell)

[`NSTextAttachmentCell-swift.class`](/documentation/AppKit/NSTextAttachmentCell-swift.class)

[`NSBrowserCell`](/documentation/AppKit/NSBrowserCell)

[`NSImageCell`](/documentation/AppKit/NSImageCell)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)