NSString stringWithContentsOfFile failing with what seems to be the wrong error code

后端 未结 6 1862
闹比i
闹比i 2021-02-12 22:33

I\'m trying to load a file into a string. Here is the code I\'m using:

NSError *error = nil;
NSString *fullPath = [[NSBundle mainBundle] pathForResource:filename         


        
6条回答
  •  抹茶落季
    2021-02-12 22:43

    I ran into the same error.

    When I played around a bit, it appeared that I was not including the file in copy bundle resources of the target.

    I did that and it worked fine.

    But, have to say -- error is quite misleading for such a simple cause. Just a bad guess from Xcode

提交回复
热议问题