我有这个功能来保存tmp文件夹中的图像
private func saveImageToTempFolder(image: UIImage, withName name: String) {
if let data = UIImageJPEGRepresentation(image, 1) {
let tempDirectoryURL = NSURL.fileURLWithPath(NSTemporaryDirectory(), isDirectory: true)
let targetURL = tempDirectoryURL.URLByAppendingPathComponent("\(name).jpg").absoluteString
print("target: \(targetURL)")
data.writeToFile(targetURL, atomically: true)
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我打开我的应用程序的临时文件夹时,它是空的.将图像保存在临时文件夹中我做错了什么?