ios - PHPhotoLibrary get album names -


i've been trying find alternative getting album names photos api in ios 8. alassets, can use: valueforproperty:alassetsgrouppropertyname photos api, can't seem find alternative. there is: localizedtitle under phassetcollection isn't right either, gives me city names. i'm looking can return actual names of groups, including ones synced itunes.

i'd appreciate see how in apps. apple encouraging use photos api apps linked 8.0, i'd rather not use both alassetlibrary , photos.

code:

- (nsstring *)nameforalbumincollection:(id)collection {     nsstring *title = nil;      if ([phasset class])     {         title = [collection localizedtitle];     }     else     {         title = [collection valueforproperty:alassetsgrouppropertyname];     }      return title; }  - (void)setup {     self.recentscollectiondatasource = [[nsmutableorderedset alloc]init];     self.favoritescollectiondatasource = [[nsmutableorderedset alloc]init];     self.albumstabledatasource = [[nsmutableorderedset alloc]init];      nsmutablearray *segmenttitles = [[nsmutablearray alloc]init];      self.assetsfetchresult = [phassetcollection fetchassetcollectionswithtype:phassetcollectiontypesmartalbum | phassetcollectiontypealbum subtype:phassetcollectionsubtypeany options:nil];      if (!self.parentcontroller.cantakeorchoosevideo)     {         fetchoptions.predicate = [nspredicate predicatewithformat:@"mediatype = %i",phassetmediatypeimage];     }      (phassetcollection *sub in self.assetsfetchresult)     {         phfetchresult *assetsincollection = [phasset fetchassetsinassetcollection:sub options:nil];          (phasset *asset in assetsincollection)         {             nslog(@"%@",[self nameforalbumincollection:sub]);              [self.recentscollectiondatasource addobject:asset];              if (![segmenttitles containsobject:@"recents"])             {                 [segmenttitles addobject:@"recents"];                 [segmenttitles addobject:@"albums"];             }              if (asset.isfavorite)             {                 [self.favoritescollectiondatasource addobject:asset];                  if (![segmenttitles containsobject:@"favorites"])                 {                     [segmenttitles addobject:@"favorites"];                 }             }         }     } } 

this how made list of album names in project of mine. may have deviate bit, should work.

nsarray *collectionsfetchresults; nsmutablearray *localizedtitles = [[nsmutablearray alloc] init];  phfetchresult *smartalbums = [phassetcollection       fetchassetcollectionswithtype:phassetcollectiontypesmartalbum                                                                       subtype:phassetcollectionsubtypealbumregular options:nil]; phfetchresult *syncedalbums = [phassetcollection fetchassetcollectionswithtype:phassetcollectiontypealbum                                                                 subtype:phassetcollectionsubtypealbumsyncedalbum options:nil]; phfetchresult *usercollections = [phcollectionlist fetchtoplevelusercollectionswithoptions:nil];  // add each phfetchresult array collectionsfetchresults = @[smartalbums, usercollections, syncedalbums];  (int = 0; < collectionsfetchresults.count; ++) {      phfetchresult *fetchresult = collectionsfetchresults[i];      (int x = 0; x < fetchresult.count; x ++) {          phcollection *collection = fetchresult[x];         localizedtitles[x] = collection.localizedtitle;      } } 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -