I wrote a simple program to help me debug.
#import "UIImage+saveScreenShotOnDisk.h"
@implementation UIImage (saveScreenShotOnDisk)
-(void)saveScreenshot{
NSData * data = UIImagePNGRepresentation(self);
[data writeToFile:@"foo.png" atomically:YES];
}
@end
After it’s executed, I want to know where foo.png is located.
I went to
~Library/Application Support
and I can’t find foo.png. Where is it?
If I do
BOOL result = [data writeToFile:@"foo.png" atomically:YES];
the result will be NO, which is kind of strange given that the simulator, unlike the iPhone, can write anywhere.
You need to direct the NSData object to the Path you want the data to be saved in:
This will save your file in your App’s Folder on the device (or the simulator).