在iOS10的Xcode8.3中,我试图将文件从Package Directory复制到Apps专用目录。这适用于iOS6,但不适用于iOS8及以上版本。
我是for循环中的索引文件:
NSString* currentfilename = [[dbfileManager directoryContentsAtPath: bundleFolderPath] objectAtIndex:i];
NSString*s =[NSString stringWithFormat:@".db"];
//NSLog(@"getAllMapDBFileNames db file exist=%@",s);
if ([currentfilename rangeOfString:s].location != NSNotFound){
NSString *tmpfilename=[[[currentfilename stringByReplacingOccurrencesOfString:@"-" withString:@" "] stringByReplacingOccurrencesOfString:@".db" withString:@""] capitalizedString];
NSString *strdestination = [NSString stringWithFormat:@"%@/%@", bundleFolderPath,currentfilename];
NSLog(@"DOES Exist! = %@",tmpfilename);
NSLog(@"strdestination = %@",strdestination);
NSString *toPath = [NSString stringWithFormat:@"%@/%@", dbappFolderPath,currentfilename];
NSLog(@"toPath = %@",toPath);
[[NSFileManager defaultManager]copyItemAtPath:strdestination toPath:toPath error:NULL]; //&Error
}
为什么iOS 8及以上阻止了这个?
答案 0 :(得分:0)
此代码实际有效!我不确定Xcode 8.3是否有文件大小限制。