NSBundle pathForResource is NULL

前端 未结 9 1002
感情败类
感情败类 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 04:59

    In my case (executing XCTestCase) for some reason resources were stored in non-main Bundle. I fixed the problem by checking first which bundle test class belongs to:

    [[NSBundle bundleForClass:[self class]] pathForResource:@"Config" ofType:@"plist"];
    

    Hopefully this can help someone else as well.

提交回复
热议问题