压缩或压缩iOS sqlite数据库 [英] compress or zip iOS sqlite Database
本文介绍了压缩或压缩iOS sqlite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
人们
如何压缩我的iOS应用的sqlite数据库?因为我试图用云计算它,但是我遇到了一些麻烦...
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!
推荐答案
您可以使用ZipArchive,它是用于压缩/解压缩的目标c包装程序- http://code.google.com/p/ziparchive/
You can use ZipArchive, its a objective c wrapper to zip/unzip - http://code.google.com/p/ziparchive/
对于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");
这篇关于压缩或压缩iOS sqlite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文