我想更改相册的标题。
所以我尝试了
- (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.)""
}];
}
第一个日志的标题更改为“newName”,但第二个日志的标题为“error CODE=-1”,我的专辑标题没有更改。我的代码有什么问题?