<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/NSTextTable",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextTable"
  },
  "title" : "NSTextTable"
}
-->

# NSTextTable

An object that represents a table of rows and columns in an attributed string.

```
class NSTextTable
```

## Overview

`NSTextTable` is a subclass of [`NSTextBlock`](/documentation/UIKit/NSTextBlock) that represents a complete table. You can configure the number of columns, whether adjacent cell borders collapse into one, and whether empty cells are hidden.

Each cell is an [`NSTextTableBlock`](/documentation/UIKit/NSTextTableBlock) that specifies its row, column, and span within the table. You don’t add cells directly to the table — instead, you apply each cell’s block to a paragraph using [`textBlocks`](/documentation/UIKit/NSParagraphStyle/textBlocks).

Choose between two layout algorithms using the [`layoutAlgorithm`](/documentation/UIKit/NSTextTable/layoutAlgorithm-swift.property) property:

- [`NSTextTable.LayoutAlgorithm.automatic`](/documentation/UIKit/NSTextTable/LayoutAlgorithm-swift.enum/automatic) distributes column widths based on content, similar to the HTML `auto` table layout.
- [`NSTextTable.LayoutAlgorithm.fixed`](/documentation/UIKit/NSTextTable/LayoutAlgorithm-swift.enum/fixed) distributes column widths based on explicit values set on the first row of cells, similar to the HTML `fixed` table layout.

## Topics

### Configuring the table

[`numberOfColumns`](/documentation/UIKit/NSTextTable/numberOfColumns)

[`layoutAlgorithm`](/documentation/UIKit/NSTextTable/layoutAlgorithm-swift.property)

[`collapsesBorders`](/documentation/UIKit/NSTextTable/collapsesBorders)

[`hidesEmptyCells`](/documentation/UIKit/NSTextTable/hidesEmptyCells)

[`LayoutAlgorithm`](/documentation/UIKit/NSTextTable/LayoutAlgorithm-swift.enum)

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

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

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

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

### Inherits From

[`NSTextBlock`](/documentation/UIKit/NSTextBlock)

---

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)