-5

Assuming that I have this array of strings: var array = ["First", "Second", "Third"] I want to show each of the elements of this array in an NSTableView cell. I have created the function numberOfRowsInSection that returns the number of empty cells, but I can't figure out how to show the string elements.

jscs
  • 63,694
  • 13
  • 151
  • 195
  • 3
    Please read [Start Developing iOS Apps (Swift) : Create a Table View](https://developer.apple.com/library/archive/referencelibrary/GettingStarted/DevelopiOSAppsSwift/CreateATableView.html) The principle in macOS is very similar. – vadian Feb 27 '19 at 19:57
  • This is a pretty basic operation. Try to write the code yourself, then if you are having issues, post your question and we can try to help you. – Russ J Feb 27 '19 at 20:01
  • All resources are for iOS development. I couldn't find the right to do it for NSTableViewCell for Mac OS. I'm just looking for the right function. –  Feb 27 '19 at 20:05
  • 1
    Here is a macOS tutorial: https://www.raywenderlich.com/830-macos-nstableview-tutorial – vadian Feb 27 '19 at 20:06

1 Answers1

1

You can use

func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
        return array[row]
    }
}
Len_X
  • 825
  • 11
  • 29