#import <AssetsLibrary/AssetsLibrary.h>
-(void) getimgs{
Dispatch_async (Dispatch_get_main_queue (), ^{
NSAutoreleasePool *pool = [[Nsautoreleasepoolalloc] init];
Alassetslibraryaccessfailureblock Failureblock = ^ (Nserror *myerror) {
NSLog (@ "album Access failed =%@", [myerrorlocalizeddescription]);
if ([Myerror.localizeddescription rangeofstring:@ "Global denied access"].location!=nsnotfound) {
NSLog (@ "Unable to access the album.) set the location services as set to open.");
}else{
NSLog (@ "album Access failed.");
}
};
Alassetsgroupenumerationresultsblock groupenumeration = ^ (Alasset *result,nsuinteger Index, BOOL *stop) {
if (result!=null) {
if ([[result Valueforproperty:alassetpropertytype]isequaltostring:alassettypephoto]) {
NSString *urlstr=[nsstring stringwithformat:@ "%@", result.defaultrepresentation.url];//picture URL
Large image of/*result.defaultrepresentation.fullscreenimage//
Thumbnail image of Result.thumbnail//Picture
Nsrange range1=[urlstr rangeofstring:@ "id="];
NSString *resultname=[urlstr substringfromindex:range1.location+3];
Resultname=[resultname stringbyreplacingoccurrencesofstring:@ "&ext=" withstring:@ "."];/ /Format Demo:123456.png
*/
[Self._dataarray ADDOBJECT:URLSTR];
}
}
};
Alassetslibrarygroupsenumerationresultsblock
Librarygroupsenumeration = ^ (alassetsgroup* group,bool* stop) {
if (group = = nil)
{
}
if (Group!=nil) {
NSString *g=[nsstring stringwithformat:@ "%@", group];//gets the group of albums
NSLog (@ "gg:%@", g);//Gg:alassetsgroup-name:camera roll, type:saved Photos, Assets count:71
NSString *g1=[g substringfromindex:16];
Nsarray *arr=[nsarray arraywitharray:[g1componentsseparatedbystring:@ ","]];
NSString *g2=[[arr Objectatindex:0]substringfromindex:5];
if ([G2 isequaltostring:@ "Camera Roll"]) {
[Email protected] "camera roll";
}
NSString the name of the *groupname=g2;//group
[Groupenumerateassetsusingblock:groupenumeration];
}
};
alassetslibrary* Library = [[Alassetslibraryalloc] init];
[Libraryenumerategroupswithtypes:alassetsgroupall
Usingblock:librarygroupsenumeration
Failureblock:failureblock];
[Library release];
[Pool release];
});
}
------------------------reverse the image based on the URL of the image---
Alassetslibrary *assetlibrary=[[alassetslibraryalloc] init];
Nsurl *url=[nsurlurlwithstring:urlstr];
[Assetlibrary assetforurl:url resultblock:^ (Alasset *asset) {
UIImage *image=[uiimage ImageWithCGImage:asset.thumbnail];
Cellimageview.image=image;
}failureblock:^ (Nserror *error) {
NSLog (@ "error=%@", error);
}
];
---------------------
Ios-get all the photos inside the system album