0

I have tried this in a variety of ways and yet it never pops out my file as a string. Any help would be much appreciated. Perhaps a fresh set of eyes can get it.

static NSString *JSParse;


JSParse = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"nameFinder" ofType:@"js" ] encoding:NSUTF8StringEncoding ];
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"nameFinder" ofType:@"js"];
NSLog(filepath);
if (filepath)
{
    NSString *someJscript = [NSString stringWithContentsOfFile:filepath];
    NSLog(someJscript);
}
NSLog(@"StartParse");
NSLog(JSParse);
NSLog(@"End Parse");

The end goal is to use javascript to parse HTML from a website that isn't mine and yes it sucks. (Parsing although my code is suspect too at this point);

Jonathan Eustace
  • 2,469
  • 12
  • 31
  • 54
Kevrone
  • 614
  • 2
  • 11
  • 22

2 Answers2

0

The Reason for this has something to do with it being a JS file extension. Changing it to a txt file invariably fixes the problem. I'm not sure why this is so but i'm assuming it's some compilation issues.

Kevrone
  • 614
  • 2
  • 11
  • 22
0

The solution is here: https://stackoverflow.com/a/2018644/526547

You don't need to change your .js to .txt if you use this method.

Community
  • 1
  • 1
Cyrille
  • 25,014
  • 12
  • 67
  • 90
  • Thanks for the clarity. Whats the odds you can help me with my mutable array http://stackoverflow.com/questions/8587818/addobjectsfromarray-not-copying-into-global-nsmutablearray – Kevrone Dec 21 '11 at 10:29