我是xcode和Swift的新手,我想知道是否有任何简单的方法将单元格添加到表格视图,类似于将选择添加到组合框的方法。到目前为止,这是我的代码。
@IBOutlet weak var labelout: NSTextField!
@IBOutlet weak var partitionbox: NSComboBox!
@IBOutlet weak var comboboxtext: NSComboBoxCell!
@IBOutlet weak var launchtable: NSTableView!
@IBOutlet weak var tabletext: NSTextFieldCell!
@IBOutlet weak var pathlist: NSCell!
override func viewDidLoad() {
super.viewDidLoad()
partitionbox.removeAllItems()
let fileManager = NSFileManager.defaultManager()
var error: NSError? = nil
let contents = fileManager.contentsOfDirectoryAtPath("/Volumes", error: &error)
partitionbox.addItemsWithObjectValues(contents!)
// Do any additional setup after loading the
}
@IBAction func refreshbuttonpress(sender: AnyObject) {
partitionbox.removeAllItems()
let fileManager = NSFileManager.defaultManager()
var error: NSError? = nil
let contents = fileManager.contentsOfDirectoryAtPath("/Volumes", error: &error)
partitionbox.addItemsWithObjectValues(contents!)
}
@IBAction func inspectbuttonpress(sender: AnyObject) {
let fileManager = NSFileManager.defaultManager()
var error: NSError? = nil
let part = comboboxtext.stringValue
let directory = part + "/Library/LaunchAgents"
let cellcontent = fileManager.contentsOfDirectoryAtPath("/Library/LaunchAgents", error: &error)
// Anything similar to addItemsWithObjectValues for TableView?
}
override var representedObject: AnyObject? {
didSet {
// Update the view, if already loaded.
}
}
我的应用目标是列出安装到操作系统的所有LaunchAgent,LaunchDaemons和Frameworks。
感谢。