Im saving my images in NSDocumentsDirectory with this:
for (int i = 0; i < info.count; i++) {
NSLog(@"%@", [info objectAtIndex:i]);
NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"oneSlotImages%d.png", i]];
ALAssetRepresentation *rep = [[info objectAtIndex: i] defaultRepresentation];
UIImage *image = [UIImage imageWithCGImage:[rep fullResolutionImage]];
NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:savedImagePath atomically:YES];
}
Im having difficulty loading them into an array. Ive searched this in the net.
Can this be use for NSDocumentsDirectory?
for(int i = 1; i <= 21; i++)
{
[images addObject:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"Images%d.png", i] ofType:@"jpg"]]];
}
Is this your actual code?
There are (at least) two problems if this is the case.
First, the file names are slightly different in the saving and loading.
Second, you load pictures from the bundle, and not from the document directory.
You would want to load them this way?
Also note, that if you have 20 images that are full res photos, then loading them in an array of UIImages is probably a terrible idea. It will probably crash for lack of memory.