JRafaelM
JRafaelM

Reputation: 881

compress or zip iOS sqlite Database

People,

How Can I Zip my iOS app's sqlite database? Because I'm trying to sinc it with the cloud but im having some troubles...

Which classes I'm supposed to use to zip it ? please help me out!

Upvotes: 1

Views: 1998

Answers (2)

saadnib
saadnib

Reputation: 11145

You can use ZipArchive, its a objective c wrapper to zip/unzip - http://code.google.com/p/ziparchive/

for zip :-

NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString* dPath = [paths objectAtIndex:0];
    NSString* txtfile = [dPath stringByAppendingPathComponent:@"test.txt"];
    NSString* zipfile = [dPath stringByAppendingPathComponent:@"test.zip"];
    ZipArchive* zip = [[ZipArchive alloc] init];
    BOOL ret = [zip CreateZipFile2:zipfile];
    ret = [zip addFileToZip:txtfile newname:@"test.txt"];//zip
    if( ![zip CloseZipFile2] )
    {
        zipfile = @"";
    }
    [zip release];
    NSLog(@"The file has been zipped");

Upvotes: 4

Saurabh Passolia
Saurabh Passolia

Reputation: 8109

you can use Zlib which is available at: http://code.google.com/p/objective-zip/

Upvotes: 0

Related Questions