objective c - How can I Change collectionList Title?? "Error Domain=NSCocoaErrorDomain Code=-1" -


i want change title of photo album.

so 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 ----- "collectionchangerequest - <phcollectionlistchangerequest: 0x170268480> title=newname hasassetchanges=0"          }      }]; } completionhandler:^(bool success, nserror *error) {     nslog(@"finished editing collection. %@", (success ? @"success." : error));     //this log result ----- "finished editing collection. error domain=nscocoaerrordomain code=-1 "the operation couldn’t completed. (cocoa error -1.)"" }]; 

}

first log changed title "newname" second log "error code=-1" , album title not changing. problem in code??

    -(void)changealbumtitle:(phassetcollection *)collection withtitle:(nsstring *)title {      if (![collection canperformeditoperation:phcollectioneditoperationrename]) {          nslog(@"can't performeditoperation");         return;     }       [[phphotolibrary sharedphotolibrary] performchanges:^{         phassetcollectionchangerequest *changetitlerequest =[phassetcollectionchangerequest changerequestforassetcollection:collection];         changetitlerequest.title = title;       } completionhandler:^(bool success, nserror *error) {             nslog(@"finished editing collection. %@", (success ? @"successfully." : error));     }];   } 

in above give function pass album object (phassetcollection ) , title

  • first function check phassetcollection can perform rename editoperation
  • if edit operation possible implement phassetcollectionchangerequest , set new title.

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -