【发布时间】:2012-02-10 15:25:49
【问题描述】:
我正在尝试将添加到名为“includes”的文件夹中的文件复制到名为“includes”的文档目录上的文件夹中。
resContents 的值为零。为什么?
- (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);;
}
}
}
【问题讨论】:
标签: iphone objective-c ios xcode cocoa-touch