I have the following code that saves user sketch data to a file ...
NSString *filename = [NSString stringWithFormat:@"%@.png", sketchID];
CGImageRef imageRef = CGBitmapContextCreateImage(paintView.canvas.mBitmapContext);
UIImage* image = [[UIImage alloc] initWithCGImage:imageRef];
NSData* imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:filename atomically:YES];
CGImageRelease(imageRef);
[image release];
SketchIDis a unique alphanumeric value, so as an example of the file name I save "p1.png". The code I use to read the file ...
if(fileName != nil)
{
UIImage* image = [UIImage imageWithContentsOfFile:fileName];
if(image != nil)
{
.
.
This code seems to work fine when run on the simulator, but when I run it on the device, the image fails to load. I'm new to iOS development, and I'm still learning how files are stored. My questions...
- Why does saving / loading a file work on a simulator and not on a device?
- , , iPhone, ? "p1.png" ,
writeToFile: imageWithContentsOfFile: ?