我正在使用此代码从我的设备中检索所有图像,但它没有返回结果
- (void)viewDidLoad
{
[super viewDidLoad];
void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result != NULL) {
NSLog(@"See Asset: %@", result);
[_assets addObject:result];
// Here storing the asset's image URL's in NSMutable array urlStoreArr
NSURL *url = [[result defaultRepresentation] url];
[_urlStoreArr addObject:url];
}
};
void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
{
if(group != nil)
{
[group enumerateAssetsUsingBlock:assetEnumerator];
}
};
_urlStoreArr = [[NSMutableArray alloc] init];
_assets = [[NSMutableArray alloc] init];
_library = [[ALAssetsLibrary alloc] init];
[_library enumerateGroupsWithTypes:ALAssetsGroupAlbum
usingBlock:assetGroupEnumerator
failureBlock: ^(NSError *error) {
NSLog(@"Failure");
}];
[self UploadImagesToServer];
}
-(void) UploadImagesToServer
{
for (int i=0; i<[_urlStoreArr count]; i++)
{
// To get the each image URL here...
NSString *str = [_urlStoreArr objectAtIndex:i];
NSLog(@"str: %@",str);
// Need to upload the images to my server..
}
}