---
title: NSTextTable
framework: uikit
role: symbol
role_heading: Class
path: uikit/nstexttable
---

# NSTextTable

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

## Declaration

```swift
class NSTextTable
```

## Mentioned in

Adding tables to attributed strings in UIKit

## Overview

Overview NSTextTable is a subclass of 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 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. Choose between two layout algorithms using the layoutAlgorithm property: NSTextTable.LayoutAlgorithm.automatic distributes column widths based on content, similar to the HTML auto table layout. NSTextTable.LayoutAlgorithm.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](uikit/nstexttable/numberofcolumns.md)
- [layoutAlgorithm](uikit/nstexttable/layoutalgorithm-swift.property.md)
- [collapsesBorders](uikit/nstexttable/collapsesborders.md)
- [hidesEmptyCells](uikit/nstexttable/hidesemptycells.md)
- [NSTextTable.LayoutAlgorithm](uikit/nstexttable/layoutalgorithm-swift.enum.md)

## Relationships

### Inherits From

- [NSTextBlock](uikit/nstextblock.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Tables

- [Adding tables to attributed strings in UIKit](uikit/adding-tables-to-attributed-strings.md)
- [NSTextTableBlock](uikit/nstexttableblock.md)
- [NSTextBlock](uikit/nstextblock.md)
