因為需求問題,今天測試了一下運行后,代碼改變mainBundle里邊文件的操作,發(fā)現(xiàn)一下情況
- 將兩張不同名字的圖片拖入工程(testImage和testImage2),核心代碼如下:
-(void)replaceImage{
NSString *testImagePath = [[NSBundle mainBundle] pathForResource:@"testImage" ofType:@"png"];
NSString *testImage2Path = [[NSBundle mainBundle] pathForResource:@"testImage2" ofType:@"png"];
NSLog(@"%@",testImage2Path);
BOOL success = [FILE_MANAGER replaceItemAtURL:[NSURL fileURLWithPath:testImagePath] withItemAtURL:[NSURL fileURLWithPath:testImage2Path] backupItemName:@"testImage.png" options:NSFileManagerItemReplacementUsingNewMetadataOnly resultingItemURL:nil error:nil];
if (success) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"tips" message:@"替換成功" delegate:self cancelButtonTitle:@"確定" otherButtonTitles:nil, nil];
[alert show];
}
}
-
結(jié)果發(fā)現(xiàn),在模擬機下是能替換的,但是,在真機下是不行的。然后拿了一些調(diào)試證書打出來的ipa包解壓修改里邊的文件,發(fā)現(xiàn)也是做了校驗的:
安裝圖片
所以不用打編譯后的mainBundle的文件的注意了,畢竟安全很重要