Monday, December 27, 2010

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

Programmer Question

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?



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails