Tag: SWIFT NSURL

从UIImagePickerController获取UIImage的URL

我试图从Swift库中导入的图像的URL用transferFile(_:metadata)发送给Apple Watch,但是我在NSURL上有两个错误。 这是我的代码: func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) { imagePicked.image = image let imageUrl = editingInfo[UIImagePickerControllerReferenceURL] as! NSURL let imageName = imageUrl.path!.lastPathComponent let documentDirectory = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first as String! let localPath = documentDirectory.stringByAppendingPathComponent(imageName) let image = editingInfo[UIImagePickerControllerOriginalImage]as! UIImage let data = UIImagePNGRepresentation(image) data!.writeToFile(localPath, atomically: true) let photoURL = NSURL(fileURLWithPath: […]