forum

Home / DeveloperSection / Forums / How to execute ALAssetLibrary code with viewDidLoad: method in iOS?

How to execute ALAssetLibrary code with viewDidLoad: method in iOS?

Anonymous User 1380 15-Jan-2016

I am new in iOS programming so I am getting some serious problem in our code. I have getting problem in our asset library code, this code is written in the viewDidLoad: method but when I run the application viewDidLoad: method executes but my asset library code is not executing, it will execute after the execution of other method of application. So, the asset urls that I am fetching from the device library I am unable to display those data into our table view.
this is my assetLibrary code it is not executing with the viewDidLoad: method:

ALAssetLibrary *assetLibrary = [[ALAssetLibrary alloc] init];
[_assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop){
 [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop){
  if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto]){
   [urls addObject:[result valueForProperty:ALAssetPropertyURLs]];
  }
 });
} failureBlock:^(NSError *error){
 NSLog(@"Failure");
}];

I google it but I don't find any perfect solution.
Please help me.


Updated on 18-Jan-2016
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By