objective c - How to zip folders in Ipad -


in application,i taking screenshots of image view , saving screen shots in document folder of application.now want email images same folder structure in.zipping folders containing images?

-(void)zipfile2{ nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *docdirectory = [paths objectatindex:0]; bool isdir=no; nsarray *subpaths; nsstring *exportpath = docdirectory; nsfilemanager *filemanager = [nsfilemanager defaultmanager]; if ([filemanager fileexistsatpath:exportpath isdirectory:&isdir] && isdir){     subpaths = [filemanager subpathsatpath:exportpath]; } nsstring *archivepath = [docdirectory stringbyappendingstring:@"uploads.zip"];     ziparchive *archiver = [[ziparchive alloc] init]; [archiver createzipfile2:archivepath]; for(nsstring *path in subpaths) {     nsstring *longpath = [exportpath stringbyappendingpathcomponent:path];     if([filemanager fileexistsatpath:longpath isdirectory:&isdir] && !isdir)     {         [archiver addfiletozip:longpath newname:path];     } } bool successcompressing = [archiver closezipfile2]; if(successcompressing)     nslog(@"success"); else     nslog(@"fail"); 

}

i use code zip file not created in ipad ??? can me

ziparchive has delegate protocol sends message whenever error occurs.

add below ziparchive allocation.

archiver.delegate = self 

add protocol header class , implement following method:

- (void)errormessage:(nsstring*) msg {     nslog(@"zip error: %@", msg); } 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -