Irrd Irrd - 5 months ago 22
Swift Question

Swift, How to get the image path from UIPickerView in iOS?

In Android there is a way to take the selected image path and display it in our app. Is there any way to do the same thing in iOS too? To select the image from the picker view, take the image path and display in my app?


UIImagePickerControllerOriginalImage returns only the image's data, with no reference to its local storage.

 func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {

     if let localUrl = (info[UIImagePickerControllerMediaURL] ?? info[UIImagePickerControllerReferenceURL]) as? NSURL {

        print (localUrl)
        //if you want to get the image name 
        let imageName = localUrl.path!.lastPathComponent

for more help see this link