iOS 8 ALAssets create group not API compatible with iOS 7 ALAssets create group
| Originator: | jesse.ditson | ||
| Number: | rdar://18519852 | Date Originated: | 12/01/2014 |
| Status: | Open | Resolved: | No |
| Product: | iOS SDK | Product Version: | 8.0 |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
in iOS 7, ALAssetsLibrary -addAssetsGroupAlbumWithName:resultBlock:failureBlock: returns either nil if the group already exists, or an ALAssetsGroup if the group was created.
in iOS 8, this behavior has changed - it returns the group the first time, and returns nil on subsequent calls, but if you delete the album, it still returns nil, and does not call the failureBlock when the group was not created. Notably, on iOS 7 it creates the album again and performs as expected.
Steps to Reproduce:
Given the following code:
void (^complete)(BOOL, NSError *) = ^(BOOL exists,NSError *error){
NSString *message = [NSString stringWithFormat:@"Image saved : %@, errored : %@",
exists ? @"YES" : @"NO",
error ? @"YES" : @"NO"];
UIAlertView *statusAlert = [[UIAlertView alloc] initWithTitle:@"Group Creation Results:" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[statusAlert show];
};
if (!self.lib) {
self.lib = [ALAssetsLibrary new];
}
__weak ALAssetsLibrary *lib = self.lib;
static NSString *groupName = @"Test album";
[lib addAssetsGroupAlbumWithName:groupName resultBlock:^(ALAssetsGroup *group) {
NSLog(@"group : %@",group);
//Check if album was previous created
if(group == nil) {
//Enumerate through albums
[lib enumerateGroupsWithTypes:ALAssetsGroupAlbum usingBlock:^(ALAssetsGroup *album, BOOL *stop) {
NSLog(@"album : %@",[album valueForProperty:ALAssetsGroupPropertyName]);
//Found Album
if ([[album valueForProperty:ALAssetsGroupPropertyName] isEqualToString:groupName]) {
complete(YES,nil);
}
} failureBlock:^(NSError *error){
complete(NO, error);
}];
} else {
complete(YES,nil);
}
} failureBlock:^(NSError *error) {
complete (NO, error);
}];
1. execute this code once
2. delete the created group from your photos
3. execute the code again (it will never hit the complete block)
Expected Results:
I expect that the above code would act like it does on iOS 7:
1. execute the code
2. delete the created group from your photos
3. execute the code again, it will hit the complete block and recreate the group.
Actual Results:
on any iOS 8 device/sim:
1. execute the code
2. delete the created group from your photos
3. execute the code again
4. group is nil, but the group was neither created nor pre-existing, so we can never re-create the album once it's deleted.
Version:
Reproduced on all simulators and devices
Notes:
Configuration:
Any device running iOS 8.0
Attachments:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!