是否有可能写入新的文件捆绑资源目录在iOS应用程序?

是否有可能写入新的文件捆绑资源目录在iOS应用程序?

不,没有办法写在捆绑目录..因为捆绑目录代码签名与SSL证书,你不能打破它。 但是你可以很容易地在你的iPhone应用程序的文档目录中写入

你可以使用这个获取文档目录path –

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); return [paths objectAtIndex:0]; 

或者您可以复制所需的资源,然后对具有写入权限的文件进行操作。

 NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = dirPaths[0]; NSString *databasePath = [documentsDir stringByAppendingString:@"/TwigitDatabase.db"]; NSFileManager *fm = [NSFileManager defaultManager]; if(![fm fileExistsAtPath:databasePath]) { // Checking whether the my database was copied earlier, though it could be saved in some preferences property. NSError *error; NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"TwigitDatabase" ofType:@"db"]; [[NSFileManager defaultManager] copyItemAtPath:soundFilePath toPath:databasePath error:&error]; NSLog(@"%@", error); }