views:

2317

answers:

6

I am developing a iPhone application, and trying to zip the file I have created in the application, is there any built in function able to do this?

A: 

Not sure if there's a built in function, but perhaps you could use an external library such as InfoZip. Or alternatively you could try implementing your own zip library, I am pretty sure Zip format specification can be found somewhere on the internet.

RWendi

RWendi
A: 

thanks RWendi, but is it possible to give a more concrete explanation for how to do it,like how to implementing our own library,or any site u can suggested for me

issac
A: 

This may be relevant -

http://stackoverflow.com/questions/230984/compression-api-on-the-iphone

+4  A: 

As Alex pointed out, I responded to this question by pointing out the NSData category contributed by users of the Cocoadev wiki. That category includes methods for dealing with zipped and gzipped data in an NSData instance (that could be read from a Zip file or written to one). This should be all you need to implement the file zipping you describe, as long as you can feed your file data into an NSData instance.

For an example of this category in action, please see the source code for my iPhone application, Molecules. I only use the method to extract data from a gzipped file (in SLSMolecule+PDB.m), but you should be able to get the basic concepts from that.

Brad Larson
A: 

thanks Larson, i believe your application will work for me but when i modified your "NSData+Gzip" source code in my application, it return the errors as shown in below,can point out to me what is the problem

"_deflate", referenced from: -[NSData(Gzip) gzipDeflate] in NSData+Gzip.o "_inflateEnd", referenced from: -[NSData(Gzip) initWithGzippedData:] in NSData+Gzip.o "inflateInit2", referenced from: -[NSData(Gzip) initWithGzippedData:] in NSData+Gzip.o "_inflate", referenced from: -[NSData(Gzip) initWithGzippedData:] in NSData+Gzip.o "_deflateEnd", referenced from: -[NSData(Gzip) gzipDeflate] in NSData+Gzip.o "deflateInit2", referenced from: -[NSData(Gzip) gzipDeflate] in NSData+Gzip.o ld: symbol(s) not found collect2: ld returned 1 exit status

issac
A: 

thanks i solve it alr

issac