Thanks for the help. I cannot find any examples using getDocumentsDirectory(). I know that the image is being saved into the Applications Documents Folder. I just am having trouble accessing the image to insert into an array.
I have tried other methods (such as NSFileManager to delete the file) to see if I am calling the file correctly and it all works.
I have posted the code below:
Code:
- (IBAction) saveImage:(id)sender;
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Screenshot Saved" message:@"A screenshot of your work has been saved to your Photos album." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert release];
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(viewImage)];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
documentsDirectory = [documentsDirectory stringByAppendingPathComponent:@"Screenshot.png"];
[imageData writeToFile:documentsDirectory atomically:YES];
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *databaseFile = [documentsDirectoryPath stringByAppendingPathComponent:@"Screenshot.png"];
[myArray addObject:databaseFile];
}