Problem Description:
Above the Apple iOS8.0, when you create an album, such as "Rd", and then manually delete the "rd" album in the album, again through the code
#import <AssetsLibrary/ALAssetsLibrary.h>
Alassetslibrary *assetslibrary = [[Alassetslibrary alloc] init]; [Assetslibrary addassetsgroupalbumwithname:@ "Rdresultblock:^ (alassetsgroup *Group) {[Groups Addobject:group];}
Failureblock:nil];
The above code can successfully create an album "RD" on an iPhone or iPad that has never created an "rd" album on IOS 8.0+;
Under IOS 8.0 is no matter what the circumstances can be created;
However, if the "RD" album has been created on iOS 8.0+, then the "RD" album has been manually deleted on the IPhone or IPad, after the code executes the group is nil;
Solution:
Now that the discovery cannot be created, look up the official documentation and find this passage
(After IOS 8.0, using the Photos framework instead of the Assets Library framework, the Photos framework provides more features and better performance in using Photo Library At work)
Apple's official Photo Framework example:
https://developer.apple.com/devcenter/download.action?path=/wwdc_2014/wwdc_2014_sample_code/ Exampleappusingphotosframework.zip
Dig carefully and then you can fix it.
IOS 8.0+ Creating album codes with the photos framework
#import <photos/photos.h
[[Phphotolibrary sharedphotolibrary] performchanges:^{[phassetcollectionchangerequest Creationrequestforassetcollectionwithtitle:@ "Rd"];} Completionhandler:^ (BOOL success, Nserror *error) { if (! Success) {NSLog (@ "Error creating album:%@", error); }}];
Resolution iOS8.0 the deleted album with the same name (IOS 8 Photos framework:create a albums with iOS8) cannot be created through code