Objective C: Can't find .js file in my mainBundle?!

Posted by Nic Hubbard on Stack Overflow See other posts from Stack Overflow or by Nic Hubbard
Published on 2010-12-27T20:43:41Z Indexed on 2010/12/27 20:54 UTC
Read the original article Hit count: 179

Filed under:
|
|
|

This is driving me crazy as I cannot figure out what in the world is going on. I load up files form you main bundle all the time, xml files, html files, etc. But, now I am trying to get the contents of a javascript file but it can never find it. I am using:

NSData *jsData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"global" ofType:@"js"]];
    if (jsData) {
        NSLog(@"%@", jsData);
    } else {
        NSLog(@"Can't find file");
        return;
    }

Even checking the [[NSBundle mainBundle] pathForResource:@"global" ofType:@"js"] string returns null.

My activity.js file is in my Resources folder, the exact location where my other files are location that work totally fine using the above method.

Why can't it find my js file?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c