<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTableView/rowView(atRow:makeIfNecessary:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTableView(im)rowViewAtRow:makeIfNecessary:"
  },
  "title" : "rowView(atRow:makeIfNecessary:)"
}
-->

# rowView(atRow:makeIfNecessary:)

Returns a row view at the specified index, creating one if necessary.

```
func rowView(atRow row: Int, makeIfNecessary: Bool) -> NSTableRowView?
```

## Parameters

`row`

The row index.

`makeIfNecessary`

<doc://com.apple.documentation/documentation/Swift/true> if a view is required, <doc://com.apple.documentation/documentation/Swift/false> if you want to update properties on a view, if one is available.

## Return Value

An instance, or subclass, of [`NSTableRowView`](/documentation/AppKit/NSTableRowView). Returning `nil` is also valid if `makeIfNecessary` is <doc://com.apple.documentation/documentation/Swift/false> and the view did not exist.

## Discussion

This method first attempts to return a currently displayed view in the visible area. If there is no visible view, and `makeIfNecessary` is <doc://com.apple.documentation/documentation/Swift/true>, a prepared temporary view is returned. If `makeIfNecessary` is <doc://com.apple.documentation/documentation/Swift/false>, and the view is not visible, `nil` is returned.

In general, `makeIfNecessary` should be <doc://com.apple.documentation/documentation/Swift/true> if you require a resulting view, and <doc://com.apple.documentation/documentation/Swift/false> if you want to update properties on a view only if it is available (generally this means it is visible).

An exception is thrown if `row` falls outside of the number of rows in the table ([`numberOfRows`](/documentation/AppKit/NSTableView/numberOfRows)). The returned result should generally not be held onto for longer than the current run loop cycle. It’s better to call [`rowView(atRow:makeIfNecessary:)`](/documentation/AppKit/NSTableView/rowView(atRow:makeIfNecessary:)) whenever a view is required.

---

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)