Resolution iOS8.0 the deleted album with the same name (IOS 8 Photos framework:create a albums with iOS8) cannot be created through code

Source: Internet
Author: User

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;

Problem Analysis:

Personal feeling is with IOS 8.0, after the album added recently Deleted (recently deleted) This feature, causing us to manually delete the "Rd" album inside the album is not completely deleted, resulting in the creation of the album although successful, but nil, because the album is created or in Rec The state of ently Deleted;

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.