【发布时间】:2012-01-20 17:42:36
【问题描述】:
我已经尝试过多种方式,但它从未将我的文件作为字符串弹出。任何帮助将非常感激。或许一双新的眼睛就能明白。
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");
最终目标是使用 javascript 从不属于我的网站解析 HTML,是的,这很糟糕。 (虽然我的代码在这一点上也很可疑,但正在解析);
【问题讨论】: