iOS post请求
//请求的url链接
NSURL *url = [NSURL URLWithString:@"http://m.weather.com.cn/data/101010100.html"]; NSError *error; NSString *jsonString = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error]; SBJsonParser *parser = [[SBJsonParser alloc]init]; NSDictionary *rootdic = [parser objectWithString:jsonString error:&error]; NSDictionary *weatherInfo = [rootdic objectForKey:@"weatherinfo"]; self.textData.text = [NSString stringWithFormat:@"%@",[weatherInfo objectForKey:@"date_y"]]; self.weather.text = [NSString stringWithFormat:@"%@",[weatherInfo objectForKey:@"weather1"]];
需要导入
#import "SBJsonParser.h"

浙公网安备 33010602011771号