When loading a local resource file in a mac app
let urlpath = NSBundle.mainBundle().pathForResource("myResource", ofType: "html");
Converting the resource path to a string
for NSURL
always returns nil
println("resource path = (urlpath)") <---resource logged ok
web.frameLoadDelegate = self;
let requesturl = NSURL(string: urlpath!)
println("URL String = (requesturl)"),<---- returns nil
let request = NSURLRequest(URL: requesturl!)
web.mainFrame.loadRequest(request)
Which presumably is why im getting the error found nil while unwrapping an Optional value
What am I missing here to correctly convert the pathForResource
to a string
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…