ココアアプリでローカルhtmlページをロードしようとする次のコードがあります...
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);
残念ながら、URL は常に null であり、escapedPath の値を見ると、「%20」がスペースをエスケープしていることがわかります。ただし、これはローカルでは機能しません。ローカル パスを正しくエスケープする stringBy 関数はありますか?
ありがとう!