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.
Asked
Active
Viewed 189 times
-5

jscs
- 63,694
- 13
- 151
- 195
-
3Please 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
-
1Here is a macOS tutorial: https://www.raywenderlich.com/830-macos-nstableview-tutorial – vadian Feb 27 '19 at 20:06
1 Answers
1
You can use
func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
return array[row]
}
}

Len_X
- 825
- 11
- 29
-
Thank you very much but it didn't work. I'm working on NSTableView for Mac not iOS. – Feb 27 '19 at 20:06
-
-
-
Thank you @Len_X , when I build the app it's still showing Table View Cell though (Which is the title) – Feb 27 '19 at 21:36