Bundle identifier如果相同的话,ipa安装解压后会在同一沙盒下,出现你所说的覆盖安装。 首先,你可以在模拟器先运行一遍你的程序,在模拟器的沙盒下找的你的应用,进去找到你不想覆盖的文件及其路径。 搞清楚了以后在你的代码里找到向沙盒拷贝资源的代码,先判断文件是否存在,不存在则拷贝。 为你提供三个方法供你参考,粘贴过来格式乱了,空格你自己处理下吧。 //获取沙盒路径 -(NSString*)GetDocumentPath:(NSString*) _filename { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *pathstr = [paths objectAtIndex:0]; NSString *ret=[NSStringstringWithFormat:@"%@/%@",pathstr,_filename]; return ret; } //获取资源路径 -(NSString*)GetResPath:(NSString*) _filename Type:(NSString*) _type { NSString *ret = [[NSBundlemainBundle] pathForResource:_filename ofType:_type]; return ret; } //判断沙盒文件是否存在并拷贝 -(bool)FileExitAndCopy:(NSString*) filename FullName:(NSString*)fullfilename Type:(NSString*) _type { if ([[NSFileManagerdefaultManager] fileExistsAtPath:[selfGetDocumentPath:fullfilename]]) { returntrue; }else { NSError *error; NSString * tapppath = [selfGetResPath:filename Type:_type]; [[NSFileManagerdefaultManager] copyItemAtPath:tapppath toPath:[selfGetDocumentPath:fullfilename] error:&error]; if ([[NSFileManagerdefaultManager] fileExistsAtPath:[selfGetDocumentPath:fullfilename]]) { returntrue; }else { returnfalse; } } returnfalse; }
本文转自http://zhidao.baidu.com/question/502866185.html
不知道有没有用,没试过