我想将添加到名为“includes”的文件夹中的文件复制到名为“includes”的文档目录上的文件夹中。我得到resContents零值。为什么?谢谢iOS从主包中复制文件到文档目录
- (void)copyResources{
NSString *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"includes"];
NSString *destPath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:@"includes"];
NSArray* resContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:sourcePath error:NULL];
for (NSString* obj in resContents){
NSError* error;
if (![[NSFileManager defaultManager] copyItemAtPath:[sourcePath stringByAppendingPathComponent:obj] toPath:[destPath stringByAppendingPathComponent:obj]
error:&error])
NSLog(@"Error: %@", error);;
}
}
太棒了,工作!谢谢 – Jaume 2012-02-10 15:47:25