background image

//重新加载表视图

-(void)reloadView:(NSDictionary*)res;

 

//开始请求 Web Service

-(void)startRequest;

 

@end

    上面的代码在 MasterViewController 定义中实现了 NSURLConnectionDelegate 协议。datas
属性用来存放从服务器

 返回的数据,定义为可变类型,是为了从服务器加载数据过程中不

断地追加到这个

datas 中。MasterViewController.m 代码如下:

/*

* 开始请求 Web Service

*/

-(void)startRequest {

NSString *strURL = [[NSString alloc] initWithFormat:

@”http://iosbook3/mynotes/webservice.php?email=%@&type=%@&action=%@”,

@”<你的 iosbook1.com 用户邮箱>”,@”JSON”,@”query”];

NSURL *url = [NSURL URLWithString:[strURL URLEncodedString]];

NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];

NSURLConnection *connection = [[NSURLConnection alloc]

initWithRequest:request

delegate:self];