簡體   English   中英

將文件夾從資源復制到iPhone SDK中的文檔

[英]Copy folder from Resource to Document in iphone sdk

我在資源中有一個子文件夾,名稱為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"];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM