i have the following code to try and load a local html page in a cocoa app…
NSString *basePath = @"file//Users/david/Documents/My Project/index.html";
NSString *escapedPath = [basePath stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSURL*url=[NSURL URLWithString:escapedPath];
NSURLRequest*request=[NSURLRequest requestWithURL:url];
NSLog(@"current file is %@", url);
Unfortunately, the url is always null, and if i look at the value of escapedPath i see ‘%20’ escaping the space. however, this doesn’t work in local. is there a stringBy function that escapes correctly for a local path?
Thanks!
For local paths you need to use
fileURLWithPath:See the docs here:
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html