I want to change the title of Photo Album.
So I tried
- (IBAction)reNameTitle:(id)sender {
PHAssetCollection *myCollection = [self.collectionArray objectAtIndex:[sender tag]];
PHFetchResult *results = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil];
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
[results enumerateObjectsUsingBlock:^(PHCollectionList *collectionList, NSUInteger idx, BOOL *stop)
{
if ([collectionList.localizedTitle isEqualToString:myCollection.localizedTitle])
{
PHCollectionListChangeRequest *collectionChangeRequest = [PHCollectionListChangeRequest changeRequestForCollectionList:collectionList];
collectionChangeRequest.title = @"newName";
NSLog(@"collectionChangeRequest - %@", collectionChangeRequest);
//This log result is ----- "collectionChangeRequest - <PHCollectionListChangeRequest: 0x170268480> title=newName hasAssetChanges=0"
}
}];
} completionHandler:^(BOOL success, NSError *error) {
NSLog(@"Finished editing collection. %@", (success ? @"Success." : error));
//This log result is ----- "Finished editing collection. Error Domain=NSCocoaErrorDomain Code=-1 "The operation couldn’t be completed. (Cocoa error -1.)""
}];
}
First log is changed title "newName" but second log is "error CODE=-1" and my album title is not changing. What is the problem in my code??