NSBundle pathForResource is NULL

前端 未结 9 963
感情败类
感情败类 2020-11-29 04:41

I\'m creating a simple application with xcode and objc and I need to load an NSDictionary from a file, but I can\'t get the path to the file using NSBundle:

         


        
9条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 05:06

    I encountered this issue today with a Command Line project.

    Luckily, the solution is easy. Simply go to "Build Phases", click on "+" and add a new "Copy Files" phase. Choose "Resources" as Destination, and add any files you want to use.

    Now you can still use [NSBundle mainBundle] and it should work!

提交回复
热议问题