osx - SWIFT: NSURL Always either Nil or unusable -


so in swift app, have function selects folder/drive - want use nsurl string. however- when print nsurl comes "optional(file:///(stuff goes here)" when make string comes nil. there i'm doing wrong? code below

@ibaction func selectdrive(sender: anyobject) {     var openpanel = nsopenpanel()     openpanel.allowsmultipleselection = false     openpanel.canchoosedirectories = true     openpanel.cancreatedirectories = true     openpanel.canchoosefiles = false     openpanel.beginwithcompletionhandler { (result) -> void in         if result == nsfilehandlingpanelokbutton {             println(openpanel.url)             self.url = openpanel.url!              var loc = string(contentsofurl: self.url)             println("location @ \(loc)")             // var str = string(system("diskutil info \(loc) | grep uuid:"))          }      } } 

i have following declared @ top

var url = nsurl() @iboutlet weak var drivelabel: nstextfield! 

any appreciated. spent couple of hours last night trying either console output come string, trying convert nsurl string, trying delete entire app...

nsopenpanel returns url file:// scheme, can string representation path property

@ibaction func selectdrive(sender: anyobject) {     var openpanel = nsopenpanel()     openpanel.allowsmultipleselection = false     openpanel.canchoosedirectories = true     openpanel.cancreatedirectories = true     openpanel.canchoosefiles = false     openpanel.beginwithcompletionhandler { (result) -> void in         if result == nsfilehandlingpanelokbutton {              self.url = openpanel.url!             println("location @ \(self.url.path!)")         }     } } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -