LAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
NSString *photoName;
NSString *photoUrl;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) =
^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if(result != NULL)
{
NSArray *arrKeys = [[result valueForProperty:
ALAssetPropertyURLs]allKeys];
if([[result valueForProperty:ALAssetPropertyType]
isEqualToString:ALAssetTypePhoto])
{
if([[UIDevice currentDevice] systemVersion]>=5.0))
{
photoName = [[result defaultRepresentation]UTI];
}
else
{
photoName = [[result defaultRepresentation]filename];
}
//Your code here
photoUrl = [[result valueForProperty:ALAssetPropertyURLs]
objectForKey:[arrKeys objectAtIndex:0]];
}
}
};
void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) =
^(ALAssetsGroup *group, BOOL *stop)
{
if(group != nil)
{
[group enumerateAssetsUsingBlock:assetEnumerator];
}
};
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:
assetGroupEnumerator failureBlock:^(NSError *error){
NSLog(@"%@",error);
}];
[pool release];
NSString *photoName;
NSString *photoUrl;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) =
^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if(result != NULL)
{
NSArray *arrKeys = [[result valueForProperty:
ALAssetPropertyURLs]allKeys];
if([[result valueForProperty:ALAssetPropertyType]
isEqualToString:ALAssetTypePhoto])
{
if([[UIDevice currentDevice] systemVersion]>=5.0))
{
photoName = [[result defaultRepresentation]UTI];
}
else
{
photoName = [[result defaultRepresentation]filename];
}
//Your code here
photoUrl = [[result valueForProperty:ALAssetPropertyURLs]
objectForKey:[arrKeys objectAtIndex:0]];
}
}
};
void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) =
^(ALAssetsGroup *group, BOOL *stop)
{
if(group != nil)
{
[group enumerateAssetsUsingBlock:assetEnumerator];
}
};
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:
assetGroupEnumerator failureBlock:^(NSError *error){
NSLog(@"%@",error);
}];
[pool release];