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"

posted @ 2015-05-19 15:09  silenltymiss  阅读(192)  评论(0)    收藏  举报