iPhone (iOS): copying files from main bundle to documents folder causes crash

后端 未结 6 1832
日久生厌
日久生厌 2020-12-10 03:46

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 director

6条回答
  •  感动是毒
    2020-12-10 04:00

    As a general programming practice, it's always best to initialize your variables with a default value:

    NSError *error = nil;
    

    In Objective-C, it is valid to send a message to nil. So, in your case, error variable would not cause a crash if it was initialized to nil.

    For more info on the subject check Sending Messages to nil section at https://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/Chapters/ocObjectsClasses.html

提交回复
热议问题