我想將添加到名爲「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