ios - How to convert NSURL to String -
i have cameravc class start :
class cameravc: uitableviewcontroller, uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate { var imagepicker = uiimagepickercontroller() var image = uiimage() var videofilepath = nsurl() ... i have function :
func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : anyobject]) { let mediatype:string = info[uiimagepickercontrollermediatype] as! string print(mediatype) if mediatype == "public.image" { self.image = info[uiimagepickercontrolleroriginalimage] as! uiimage if self.imagepicker.sourcetype == uiimagepickercontrollersourcetype.camera { uiimagewritetosavedphotosalbum(self.image, nil, nil, nil) } self.dismissviewcontrolleranimated(true, completion: nil) } else if mediatype == "public.movie" { self.videofilepath = info[uiimagepickercontrollermediaurl] as! nsurl print(self.videofilepath) // line not work -> let url = nsurl(string: self.videofilepath) /*if self.imagepicker.sourcetype == uiimagepickercontrollersourcetype.camera { if uivideoatpathiscompatiblewithsavedphotosalbum(self.videofilepath) { uisavevideoatpathtosavedphotosalbum(self.videofilepath, nil, nil, nil) } }*/ } } the line :
let url = nsurl(string: self.videofilepath) is not working , have red alert "cannot convert value of type nsurl expected argument type string.
the line :
print(self.videofilepath) write in console log :
file:///private/var/mobile/containers/data/application/071bca9c-d246-4d14-9d56-34057a17079b/tmp/capture-t0x156501280.tmp.y4ve7u/capturedvideo.mov
if have self.videofilepath nsurl, don't have convert string , nsurl
to keep code safer:
if let path = info[uiimagepickercontrollermediaurl] as? nsurl { self.videofilepath = path let url = path //continue whatever want }
Comments
Post a Comment