0
我在我的設置屏幕中有幾個NSPathControls。我希望能夠從NSUserDefaults中檢索存儲的設置,並用存儲的URL初始化NSPathControl的NSPathComponentCell。如何設置NSPathComponentCell的URL?
目前,我有以下代碼:
class SettingsViewController: NSViewController {
let userDefaults = NSUserDefaults.standardUserDefaults()
var designFolderPath:String = String()
var developmentFolderPath:String = String()
@IBOutlet weak var designFolder: NSPathControl!
@IBOutlet weak var developmentFolder: NSPathControl!
@IBAction func saveUserSettings(sender: AnyObject) {
saveUserSettings()
}
func saveUserSettings() {
designFolderPath = designFolder.URL!.absoluteString
developmentFolderPath = developmentFolder.URL!.absoluteString
userDefaults.setObject(designFolderPath, forKey: "designFolder")
userDefaults.setObject(developmentFolderPath, forKey: "developmentFolder")
dismissController(self)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do view setup here.
// let designFolderURL:NSURL = NSURL(fileURLWithPath: designFolderPath, isDirectory: true)
// designFolder.setPathComponentCells(NSPathComponentCell.URL(designFolderURL, resourceDataDidBecomeAvailable: <#T##NSData#>))
}
override func viewDidDisappear() {
}
}
在viewDidLoad中註釋掉線()方法,我試圖用一個URL來初始化NSPathComponentCell,但我不知道該怎麼傳爲NSData的?這是正確的方法嗎?