Created
February 5, 2016 14:04
-
-
Save azizdev/5efe9620361cf11f7503 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getDirToImage(name : String) -> String { | |
let appDir = NSTemporaryDirectory() | |
let fullPath = String("\(appDir)\(name).jpeg") | |
return fullPath | |
} | |
func saveImage(image : UIImage, name: String){ | |
let data = UIImageJPEGRepresentation(image, 1.0); | |
let fileManager : NSFileManager = NSFileManager.defaultManager() | |
// let appDir = NSSearchPathForDirectoriesInDomains(.LibraryDirectory,.UserDomainMask, true) | |
// let fullPath = String("\(appDir.first)/\(name).jpeg") | |
let appDir = NSTemporaryDirectory() | |
let fullPath = String("\(appDir)\(name).jpeg") | |
print("fullPath \(fullPath)") | |
fileManager.createFileAtPath(fullPath, contents: data, attributes: nil) | |
} | |
func loadImage(name: String) -> UIImage{ | |
let appDir = NSTemporaryDirectory() | |
let fullPath = String("\(appDir)\(name).jpeg") | |
let img = UIImage(contentsOfFile: fullPath) | |
return img! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment