aryaxt
aryaxt

Reputation: 77596

Nib files cannot be loaded by name from main bundle

It seems as though my nib files are included in my test target, they don't exist in the main bundle, so my app crashes on me when I am loding a nib by its name from the main bundle. I either need to find the correct bundle that includes my nib file, or I need to load a nib using a path.

Does anyone have a solution for either one? [NSBundle bundleForClass:[self class]] doesn't work. I think the nib and class files are not in the same bundle

Upvotes: 0

Views: 799

Answers (1)

bryanmac
bryanmac

Reputation: 39296

It might help to enumerate the bundles

for (NSBundle *bundle in [NSBundle allBundles])
{
    // can look for resources in bundle
    locatedPath = [bundle pathForResource:resourcePath ofType:type];

    // or maybe trying and load the nib from it?
    UINib *nib = [UINib nibWithName:@"Blah" bundle:bundle];

    // check for !nil ...
}

Upvotes: 1

Related Questions