I save an image using this:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Image.png"];
[UIImagePNGRepresentation(image) writeToFile:filePath atomically:YES];
Then, I exit the app in the simulator. Then I attempt to load the image with this:
let imageName = "Image.png"
let image = UIImage(named: imageName)
i1.image = image
I can think of two reasons the image does not load:
- Exiting the app in the simulator is causing it to be uninstalled.
- I am not getting the paths correct in swift vs. obj-c.
Aucun commentaire:
Enregistrer un commentaire