func documentDir() -> String {
let dir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
return dir[0] as String
}
func loadStampImageByName(fishname: String) -> UIImage {
let manager = FileManager()
let docDir = self.documentDir()
let filePath = docDir.appendingFormat("/saved/\(fishname).png")
//let filePath = docDir.appendingPathComponent("/saved/pics/\(fishname).png")
//let fileUrl = NSURL(fileURLWithPath: filePath).absoluteString!
//let path = fileUrl.replacingOccurrences(of: "file://", with: "")
//print(path)
if manager.fileExists(atPath: filePath) {
let img = UIImage(contentsOfFile: filePath)
print("load 1: \(filePath)")
return img!
} else {
print("load 2")
var hola = manager.urls(for: .documentDirectory, in: .userDomainMask)[0].path
hola = hola.appendingPathComponent("saved")
let yale = try? manager.contentsOfDirectory(atPath:hola)
print(yale)
return UIImage()
}
}