ios - How to get the path of multiple images selected from library in iPhone? -


i new in iphone app development. in code, able select multiple images library , path of 1 image. creating copy of image in documents directory in folder called "images" , trying zip it. want path of selected multiple images, copy them in documents directory in same folder "images" , want zip them later. please tell me how can above mentioned tasks in code. how code looks of now:

- (void) imagepickercontroller:(qbimagepickercontroller *)imagepickercontroller didfinishpickingmediawithinfo:(nsdictionary *)info {    if (imagepickercontroller.allowsmultipleselection) {     nsarray *mediainfoarray = (nsarray *)info;     nslog(@"selected %d photos", mediainfoarray.count);     nsdata *webdata = uiimagepngrepresentation([[mediainfoarray objectatindex:0] objectforkey:@"uiimagepickercontrolleroriginalimage"]);    nslog(@"web data length is: %u",[webdata length]);    nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes);    nsstring *documentsdirectory = [paths objectatindex:0];    nsstring *localfilepath = [documentsdirectory stringbyappendingstring:@"/images.png"];    [webdata writetofile:localfilepath atomically:yes];     nslog(@"localfilepath.%@",localfilepath); } 

i used same qbimagepickercontroller , have added multiple images in nsmutablearray using method below. please check, once added array can add them wherever require.

- (void)imagepickercontroller:(qbimagepickercontroller *)imagepickercontroller didfinishpickingmediawithinfo:(id)info     {         if(imagepickercontroller.allowsmultipleselection)         {             nsarray *mediainfoarray = (nsarray *)info;                     (int =0; i<mediainfoarray.count ; i++)             {                 nsstring *stringpath = [[nssearchpathfordirectoriesindomains(nscachesdirectory, nsuserdomainmask, yes)objectatindex:0]stringbyappendingpathcomponent:@"/folder/selected files"];                 dispatch_async(dispatch_get_main_queue(), ^{                     nsdata *data = uiimagejpegrepresentation([[mediainfoarray valueforkey:@"uiimagepickercontrolleroriginalimage"] objectatindex:i], 1.0);                     nsstring *filename = [stringpath stringbyappendingpathcomponent:[nsstring stringwithformat:@"image%d.png",i]];                     [data writetofile:filename atomically:yes];                 });                 [imagesarray addobject:[[mediainfoarray valueforkey:@"uiimagepickercontrolleroriginalimage"] objectatindex:i]];             }         }         else         {             //nsdictionary *mediainfo = (nsdictionary *)info;             //nslog(@"selected: %@", mediainfo);         }         }                [tableview reloaddata];                 [self dismissviewcontrolleranimated:yes completion:null];     } 

hope helps ...

edit :

well gave better solution saving in cache directory better in documents directory please check is saving in nsdocumentdirectory okay?

but if want save in documents directory anyway can replace

nsstring *stringpath = [[nssearchpathfordirectoriesindomains(nscachesdirectory, nsuserdomainmask, yes)objectatindex:0]stringbyappendingpathcomponent:@"/folder/selected files"];

with

 nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *savedimagepath = [documentsdirectory stringbyappendingpathcomponent:@"savedimage.png"]; 

Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -