語言:Swift 2
撰寫:OS X
介面:Xcode 7
已宣告一個二維陣列
var JData: [[Int32]] = Array(count: 300, repeatedValue:
Array(count: 23, repeatedValue: 0))
並連線SQLite匯入到JData裡
在ViewController.swift中
func tableView(tableView: NSTableView,
viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView? {
if let cellView = tableView.makeViewWithIdentifier
(tableColumn!.identifier, owner: self) as? NSTableCellView {
switch tableColumn!.identifier {
case "uidY": cellView.textField?.stringValue
= "\(JData[i][1])"
case "uidH": cellView.textField?.stringValue
= "\(JData[i][2])"
}
}
}
//JData[i][1]:欲顯示第i列資料,但在func tableView裡的寫法應有誤
請問:
1. 因為會新增筆數(新增列數),所以二維陣列應如何宣告與設初始值較佳?
2. 如何顯示所有二維資料JData?以及指定範圍的資料?
懇請指點
謝謝