Tôi đang cố sao chép các tệp mà tôi thêm vào thư mục có tên "bao gồm" vào thư mục trên thư mục tài liệu cũng được gọi là "bao gồm". Tôi nhận được cho resContents giá trị nil. Tại sao? Cảm ơn bạnCác tệp sao chép iOS từ gói chính vào thư mục tài liệu
- (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);;
}
}
tuyệt vời, đang hoạt động! cảm ơn – Jaume