|
|
1
4
我的解决方案是在我的Mac上设置一个zip文件,然后让iPhone应用程序检测是否下载了这些资产,如果没有,从Mac上抓取它们并解压缩。然后这个应用程序很瘦,可以下载它需要的东西。这只是为了调试的目的,最后,您希望安装所有的资产,这样人们就不必在安装之后下载。相关的代码看起来是这样的(没有错误检查,您可能需要调整路径)。我一直在使用优秀的ASHTTP library 和 ZIPArchive 项目。您需要更改下载URL。 BOOL isDirectory;
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:installDirectory isDirectory:&isDirectory];
NSLog ( @"Checking for file: %@", installDirectory );
if ( !fileExists ) {
NSString* path = [docsPath stringByAppendingString:@"foo.zip"];
NSLog ( @"Download file!" );
NSURL *url = [NSURL URLWithString:@"http://10.0.0.11/~blezek/foo.zip"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadDestinationPath:path];
[request startSynchronous];
// Now unzip
ZipArchive *zipper = [[[ZipArchive alloc] init] autorelease];
[zipper UnzipOpenFile:path];
[zipper UnzipFileTo:docsPath overWrite:NO];
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath:path error:NULL];
}
|
|
|
2
3
Xcode显然支持增量更新,这就是为什么有时候“构建并运行”不能完成完整的应用程序更新(这很烦人)。 最简单的方法可能是将内容“安装”到文档或类似文档中,这会在应用程序更新中持续存在。希望它能移动文件而不是复制。 |