ios - array of images in document directory -


i have select multiple images from iphone through elc controller. the images are stored in array now i want to store this array of images in document directory so please help me someone..

- (void)elcimagepickercontroller:(elcimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsarray *)info { if ([self respondstoselector:@selector(dismissviewcontrolleranimated:completion:)]){     [self dismissviewcontrolleranimated:yes completion:nil]; } else {     [self dismissmodalviewcontrolleranimated:yes]; }  (uiview *v in [_scrollview subviews]) {     [v removefromsuperview]; }  cgrect workingframe = _scrollview.frame; workingframe.origin.x = 0;  nsmutablearray *images = [nsmutablearray arraywithcapacity:[info count]];   for(nsdictionary *dict in info) {      uiimage *image = [dict objectforkey:uiimagepickercontrolleroriginalimage];     [images addobject:image];      uiimageview *imageview = [[uiimageview alloc] initwithimage:image];     [imageview setcontentmode:uiviewcontentmodescaleaspectfit];     imageview.frame = workingframe;      [_scrollview addsubview:imageview];     [imageview release];      workingframe.origin.x = workingframe.origin.x + workingframe.size.width; }  self.chosenimages = images; nslog(@"values=%@",_chosenimages);  [_scrollview setpagingenabled:yes]; [_scrollview setcontentsize:cgsizemake(workingframe.origin.x, workingframe.size.height)]; } 

  1. for each of images in images array, write file file 1 one.

    nsstring *adocumentsdirectory = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) lastobject];  nsinteger anindex = 0; (uiimage *animage in images) {    nsstring *animagename = [nsstring stringwithformat:@"%d.png", anindex++];    nsstring *animagepath = [nsstring stringwithformat:@"%@/%@", adocumentsdirectory, animagename];     nsdata *animagedata = uiimagepngrepresentation(animage);   [animagedata writetofile:animagepath atomically:yes]; } 

2.. when extract original image, save image file right there.

    nsstring *adocumentsdirectory = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) lastobject];     nsinteger anindex = 0;      for(nsdictionary *dict in info) {        uiimage *image = [dict objectforkey:uiimagepickercontrolleroriginalimage];        [images addobject:image];         uiimageview *imageview = [[uiimageview alloc] initwithimage:image];        [imageview setcontentmode:uiviewcontentmodescaleaspectfit];        imageview.frame = workingframe;         [_scrollview addsubview:imageview];        [imageview release];         workingframe.origin.x = workingframe.origin.x + workingframe.size.width;         // save image        nsstring *animagename = [nsstring stringwithformat:@"%d.png", anindex++];        nsstring *animagepath = [nsstring stringwithformat:@"%@/%@", adocumentsdirectory, animagename];         nsdata *animagedata = uiimagepngrepresentation(image);        [animagedata writetofile:animagepath atomically:yes]; } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -