ios - Objective-C/ALAssetLibrary - How read and save informations about images -


i have found informations images inside emulator using alassetlibrary. can show correctly these informations using nslog, don't know how can save these informations inside list example. code i'm using this:

nsmutablearray *list = [[nsmutablearray alloc] init]; alassetslibrary* library = [[alassetslibrary alloc] init]; [library enumerategroupswithtypes:alassetsgroupall usingblock:^(alassetsgroup *group, bool *stop) {     if (group) {         [group setassetsfilter:[alassetsfilter allphotos]];         [group enumerateassetsusingblock:^(alasset *asset, nsuinteger index, bool *stop){             if (asset){                 nsstring *description = [asset description];                 nsrange first = [description rangeofstring:@"urls:"];                 nsrange second = [description rangeofstring:@"?id="];                 nsstring *path = [description substringwithrange: nsmakerange(first.location + first.length, second.location - (first.location + first.length))];                 nslog(@"path: %@", path);                 [list addobject:path];                 nsdictionary *data = [[asset defaultrepresentation] metadata];                 nsnumber *width = [[[asset defaultrepresentation] metadata] objectforkey:@"pixelwidth"];                 nsstring *widthstring = [nsstring stringwithformat:@"%@", width];             }         }];     } } failureblock:^(nserror *error) {     nslog(@"error enumerating assetlibrary groups %@\n", error); }]; nslog(@"list: %@", list); 

for i'm understanding, these operations works asynchronously, don't know how can save them. idea?

thanks

why not create mutable array , on each pass through enumeration export values care array. way, you'll have indexed list of items accessible. here's example:

nsmutablearray *mycontainerarray = [nsmutablearray new];  alassetslibrary* library = [[alassetslibrary alloc] init]; [library enumerategroupswithtypes:alassetsgroupall usingblock:^(alassetsgroup *group, bool *stop) {     if (group) {         [group setassetsfilter:[alassetsfilter allphotos]];         [group enumerateassetsusingblock:^(alasset *asset, nsuinteger index, bool *stop){             if (asset){                 nsstring *description = [asset description];                 nsrange first = [description rangeofstring:@"urls:"];                 nsrange second = [description rangeofstring:@"?id="];                 nsstring *path = [description substringwithrange: nsmakerange(first.location + first.length, second.location - (first.location + first.length))];                 nslog(@"path: %@", path);                  nsnumber *width = [[[asset defaultrepresentation] metadata] objectforkey:@"pixelwidth"];                 nsstring *widthstring = [nsstring stringwithformat:@"%@", width];                  [mycontainerarray addobject:widthstring];             }         }];     } } failureblock:^(nserror *error) {     nslog(@"error enumerating assetlibrary groups %@\n", error); }]; 

now keep in mind, i've create local variable example, , you'd need create 1 of larger scope able access array elsewhere. can access elements of array index using either [array objectatindex:i]; or modern objective c syntax array[i];.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -