<bdo id='1N6Dk'></bdo><ul id='1N6Dk'></ul>
    <i id='1N6Dk'><tr id='1N6Dk'><dt id='1N6Dk'><q id='1N6Dk'><span id='1N6Dk'><b id='1N6Dk'><form id='1N6Dk'><ins id='1N6Dk'></ins><ul id='1N6Dk'></ul><sub id='1N6Dk'></sub></form><legend id='1N6Dk'></legend><bdo id='1N6Dk'><pre id='1N6Dk'><center id='1N6Dk'></center></pre></bdo></b><th id='1N6Dk'></th></span></q></dt></tr></i><div id='1N6Dk'><tfoot id='1N6Dk'></tfoot><dl id='1N6Dk'><fieldset id='1N6Dk'></fieldset></dl></div>

      <small id='1N6Dk'></small><noframes id='1N6Dk'>

      <legend id='1N6Dk'><style id='1N6Dk'><dir id='1N6Dk'><q id='1N6Dk'></q></dir></style></legend>
    1. <tfoot id='1N6Dk'></tfoot>

      iPhone (iOS):将文件从主包复制到文档文件夹会导致崩溃

      时间:2023-10-03

      <tfoot id='6wyJO'></tfoot>
      • <small id='6wyJO'></small><noframes id='6wyJO'>

        <legend id='6wyJO'><style id='6wyJO'><dir id='6wyJO'><q id='6wyJO'></q></dir></style></legend>
        <i id='6wyJO'><tr id='6wyJO'><dt id='6wyJO'><q id='6wyJO'><span id='6wyJO'><b id='6wyJO'><form id='6wyJO'><ins id='6wyJO'></ins><ul id='6wyJO'></ul><sub id='6wyJO'></sub></form><legend id='6wyJO'></legend><bdo id='6wyJO'><pre id='6wyJO'><center id='6wyJO'></center></pre></bdo></b><th id='6wyJO'></th></span></q></dt></tr></i><div id='6wyJO'><tfoot id='6wyJO'></tfoot><dl id='6wyJO'><fieldset id='6wyJO'></fieldset></dl></div>
          <tbody id='6wyJO'></tbody>
        • <bdo id='6wyJO'></bdo><ul id='6wyJO'></ul>

                本文介绍了iPhone (iOS):将文件从主包复制到文档文件夹会导致崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试设置我的应用程序,以便在首次启动时,将位于主包中Populator"文件夹中的一系列文件复制到文档目录中.

                I am trying to set up my application so that on first launch, a series of files located in the "Populator" folder in the main bundle are copied into the documents directory.

                我目前的实现如下:

                - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
                
                  NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
                  NSString *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Populator"];
                  NSString *folderPath = [documentsDirectory stringByAppendingPathComponent:@"Files"];
                  NSLog(@"Source Path: %@
                 Documents Path: %@ 
                 Folder Path: %@", sourcePath, documentsDirectory, folderPath);
                
                  NSError *error;
                
                  [[NSFileManager defaultManager] copyItemAtPath:sourcePath 
                                                        toPath:folderPath
                                                         error:&error];
                
                  NSLog(@"Error description-%@ 
                ", [error localizedDescription]);
                  NSLog(@"Error reason-%@", [error localizedFailureReason]);
                  ....
                  return YES;
                }
                

                但是,它在第一次运行时会崩溃,并显示以下控制台消息(但文件已被复制).下次打开应用时,它不会崩溃.

                However this crashes the first time it is run with the following console messages (but the files are copied over). The next time the app is opened, it does not crash.

                    2010-07-13 15:14:26.418 AppName[5201:207] Source Path: /Users/jack/Library/Application Support/iPhone Simulator/3.2/Applications/1076C1FA-60B0-4AC7-8CD4-74F81472DAE6/AppName.app/Populator
                 Documents Path: /Users/jack/Library/Application Support/iPhone Simulator/3.2/Applications/1076C1FA-60B0-4AC7-8CD4-74F81472DAE6/Documents 
                 Folder Path: /Users/jack/Library/Application Support/iPhone Simulator/3.2/Applications/1076C1FA-60B0-4AC7-8CD4-74F81472DAE6/Documents/Files
                2010-07-13 15:14:26.466 AppName[5201:207] *** +[AppNameAppDelegate localizedDescription]: unrecognized selector sent to class 0xa79c
                2010-07-13 15:14:26.475 AppName[5201:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[AppNameAppDelegate localizedDescription]: unrecognized selector sent to class 0xa79c'
                2010-07-13 15:14:26.495 AppName[5201:207] Stack: (
                    40911435,
                    2569270537,
                    41183227,
                    40645910,
                    40642578,
                    9142,
                    2815466,
                    2819475,
                    2844680,
                    2826401,
                    2858055,
                    49271164,
                    40452156,
                    40448072,
                    2817668,
                    2850273,
                    8776,
                    8630
                )
                

                有人对出了什么问题有任何建议吗?我已经设置了一些代码来实现仅在首次启动时"功能,但为了清楚起见,这里没有包含它.

                Does anyone have any suggestions as to what is going wrong? I already have some code set up to implement the "only on first launch" functionality, but have not included it here for clarity.

                谢谢

                推荐答案

                我对iPhone编程或Objective C不太了解,但是出于好奇,如果复制操作确实成功了,那会出现什么错误?如果没有错误,会不会是日志行崩溃了?

                I don't know a lot about iPhone programming or objective C, but out of curiosity, what is error in that case if the copy operation actually succeeded? Could it be the log lines that are crashing if there was no error?

                另外,你可以像那样复制子目录的全部内容吗?(同样,我不熟悉 iOS API,只是根据我对其他语言/API 的了解来识别可能的错误来源)

                [edit] Also, are you allowed to copy the entire contents of a subdirectory like that? (Again, I'm unfamiliar with the iOS API, just identifying possible sources of error based on what I know of other languages/APIs)

                这篇关于iPhone (iOS):将文件从主包复制到文档文件夹会导致崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:ClLocationCoordinate2D 的 NSMutableArray 下一篇:连接蓝牙键盘时强制屏幕键盘显示

                相关文章

                <legend id='MbzXK'><style id='MbzXK'><dir id='MbzXK'><q id='MbzXK'></q></dir></style></legend>
                • <bdo id='MbzXK'></bdo><ul id='MbzXK'></ul>

                  <small id='MbzXK'></small><noframes id='MbzXK'>

                  <i id='MbzXK'><tr id='MbzXK'><dt id='MbzXK'><q id='MbzXK'><span id='MbzXK'><b id='MbzXK'><form id='MbzXK'><ins id='MbzXK'></ins><ul id='MbzXK'></ul><sub id='MbzXK'></sub></form><legend id='MbzXK'></legend><bdo id='MbzXK'><pre id='MbzXK'><center id='MbzXK'></center></pre></bdo></b><th id='MbzXK'></th></span></q></dt></tr></i><div id='MbzXK'><tfoot id='MbzXK'></tfoot><dl id='MbzXK'><fieldset id='MbzXK'></fieldset></dl></div>
                  <tfoot id='MbzXK'></tfoot>