I am very new to iOS and Objective-C, but I am trying to create an app that contains a component that takes all of the images from the camera roll and creates a slideshow from them. I believe the first step is to create an array from all of the images stored in the camera roll. Then I can create an animation from this array. Currently, I have a button, designated as "play", that when selected should display this slideshow as a UIImageView. However, my code does not work right now. Any help or suggestions would be greatly appreciated. Here is my code so far:
- (IBAction)play:(id)sender {
NSMutableArray *allPhotos= [[NSMutableArray alloc]init];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
if (result == nil) {
return;
}
ALAssetRepresentation *representation = [result defaultRepresentation];
UIImage *image = [UIImage imageWithCGImage:[representation fullScreenImage]];
[allPhotos addObject:image];
}];
} failureBlock: ^(NSError *error) {
NSLog(@"No groups");
}];
UIImageView *animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(60, 95, 86, 193)];
animationImageView.animationImages = allPhotos;
animationImageView.animationDuration = 0.5;
[self.view addSubview:animationImageView];
[animationImageView startAnimating];
}