我有一个带有一些预定义工具配置的图形应用程序。在应用程序的第一次午餐时,我想从包的内部将这些默认配置文件复制到 ~/Library/Containers//Data/Library/... 中。怎么做?
问问题
53 次
1 回答
0
试试这个它会帮助你。
-(void)copy
{
NSFileManager *filemanager = [NSFileManager defaultManager];
NSError *error;
NSString *path = [self getPath];
BOOL sucess = [filemanager fileExistsAtPath:path];
if(!sucess){
NSString *defaultPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"/*put your assets name with extension here */"];
sucess = [filemanager copyItemAtPath:defaultPath toPath:path error:&error];
if (!sucess) {
NSAssert1(0, @"Failed '%@'.", [error localizedDescription]);
}
}
}
-(NSString *) getPath{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
return [documentsDir stringByAppendingPathComponent:@"/*put your assets name with extension here */"];
}
于 2013-04-19T10:06:41.930 回答