iphone - 在iphone sdk中将文件夹从资源复制到文档

标签 iphone objective-c ios ios4

我在资源中有一个名为 SketchImages 的子文件夹,其中包含 300 张 PNG 图像,我需要做的是在我的应用程序启动时将此文件夹复制到 iphone sdk 的文档文件夹中,我正在尝试以下代码但没有成功

BOOL success;
NSFileManager *fileManager = [[NSFileManager defaultManager] init];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory,
                                                     NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *documentDBFolderPath = [documentsDirectory     
stringByAppendingPathComponent:@"SketchImages"];
success = [fileManager fileExistsAtPath:documentDBFolderPath];

if (success)
{
    return;
}else
{
    NSString *resourceDBFolderPath = [[[NSBundle mainBundle] resourcePath]
                                      stringByAppendingPathComponent:@"DB"];
    //[fileManager createDirectoryAtPath: documentDBFolderPath attributes:nil];
    [fileManager copyItemAtPath:resourceDBFolderPath toPath:documentDBFolderPath           
                          error:&error];
}

我们将不胜感激任何帮助

最佳答案

您使用了错误的子文件夹名称:

NSString *resourceDBFolderPath = [[[NSBundle mainBundle] resourcePath]
    stringByAppendingPathComponent:@"SketchImages"];

关于iphone - 在iphone sdk中将文件夹从资源复制到文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9528287/

相关文章:

ios - Sprite 套件碰撞 : ignore transparency?

iphone - 对象的 NSArray 和 Casting

ios - iPhone 6 Plus 中的搜索图标变形 - 被压成蛋形

ios - iPhone 6 和 iPhone 6 Plus 上页面 View Controller 的奇怪行为

iphone - 如何通过媒体查询区分 Android 和 iPad?

ios - ShareThis:Ign Github - 无法关闭 iPad 上弹出的电子邮件。需要关闭应用程序编辑

ios - 调整文本大小以适合时,如何删除 UILabel 末尾的 "..."?

ios - 使用 sqlite 时出现 6MB 内存泄漏

iphone - 是否可以在 iPhone SDK 中使用 HTTP 实时流读取元数据

iphone - 应用程序崩溃 iPhone 5 及以下