stosha
stosha

Reputation: 2148

bundlePath is nil but NSLog prints right path

I try to get resource from bundle inside framework. As you can see bundlePath is nil. But NSLog prints right path. And bundle is nil. Why?

enter image description here

Upvotes: 0

Views: 161

Answers (1)

trojanfoe
trojanfoe

Reputation: 122391

Not sure why it's happening, but the code is inefficient given you get a bundle in order to allocate a new one. This is clearly unnecessary:

NSBundle *bundle = [NSBundle mainBundle];
NSURL *modelURL = [bundle URLForResource:... ];

I missed the framework-element when answering this question. As you are calling this code from within the framework code I assume that [NSBundle mainBundle] is returning the bundle of the framework and not the app.

The answer lies in the app providing the framework code with the app's bundle via some method. The framework code should then be able to access files within the app bundle.

Upvotes: 1

Related Questions