获取沙盒中文件路径以及文件复制

1
//路径获取
NSString *path = [[NSBundle mainBundle]pathForResource:@"Phone"ofType:@"plist"];

//将沙盒中plist复制到document文件夹中

+ (BOOL)existingFileWithName:(NSString *)name type:(NSString *)type

{
    BOOL result = NO;

    NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; //获取document文件夹路径

    NSString *nowPath = [NSString stringWithFormat:@"%@/%@.%@",path,name,type];    

    NSString *sourcePath = [[NSBundlemainBundle]pathForResource:name ofType:type];

    //NSFileManager单例类

    if ([[NSFileManagerdefaultManager] fileExistsAtPath:nowPath]) {

        result = YES;

    }else{

        [[NSFileManagerdefaultManager] copyItemAtPath:sourcePath toPath:nowPath error:Nil];

    }

    NSLog(@"%@",path);

    return result;

}