background image

终于开始写代码了,公用代码:
1.将 url 地址定义成字符串常量
2.import 相应文件;
3.连接到测试的 url;
4.取得 json 数据,并将其以字符串的形式显示在第一个 TextView 上;
5.将解析后的 JSON 实际内容显示在第二个 TextView 上

1

//为了方便,先在工程中的 .pch 文件中定义 字符串常量 

2

#define jsonSourceURLAddress_1 @"http://m.weather.com.cn/data/101010100.html" 

3

#define 

jsonSourceURLAddress_2 

@"http://www.weather.com.cn/data/sk/101010100.html" 
4

#define 

jsonSourceURLAddress_3 

@"http://www.weather.com.cn/data/cityinfo/101010100.html 
5

#import "LTRootViewController.h" 

6

//测试工程中 3 中方式都是在这个 controller 中使用,将需要的 import 进来 

7

#import "SBJson.h" 

8

#import "TouchJSON/JSON/CJSONDeserializer.h" 

9

#import "JSONKit/JSONKit.h" 

10 - (void)viewDidLoad 
11 { 
12     [super viewDidLoad]; 
13     //向开源的地址发送连接请求 
14     //这里使用的是异步的请求 

                   找软件资料,就到一览软件文库

http://wk.yl1001.com/rj/