简体   繁体   中英

Parsed Json data in webView

I want to open data from my json database in a webview.

Here is my code, but it doesn't work can someone help me?

NSString* jsonString = @"http://heurigenapp.cache.gugler.at/json.php";
NSData* jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary* jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:NULL];
NSString* link = [jsonDict objectForKey:@"Link"];
NSURLRequest* linkUrl = [NSURL URLWithString:link];
[webView loadRequest:linkUrl];   

get your link in NSURL object and then set request with this NSURL object like bellow..

NSURLRequest *urlRequest;
NSURL *urlforWebView;
urlforWebView=[NSURL URLWithString:[jsonDict objectForKey:@"Link"]];
urlRequest=[NSURLRequest requestWithURL:urlforWebView];
[webView loadRequest:urlRequest];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM