有一个NSString,我需要传递这个变量加载一个webView,但是应用到这就崩溃了。但是不知道哪里出错了?请高手帮忙指教一下。
[webView loadRequest:[NSURLRequest requestWithURL:[NSString
stringWithFormat:@"http://www.website.com/page.php?status=%@", status]]];
非常感谢。
我知道了。requestWithURL
接受NSURL
, 转换成了NSURL
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.website.com/page.php?status=%@", status]]]];
NSString *urlAddress = [NSString stringWithFormat:@"http://www.website.com/page.php?status=%@", status];
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
+[NSURLRequest requestWithURL:]
需要一个 NSURL 对象,但是你传递了一个 NSString 给它。:)