AFN

#import"AFNetworkReachabilityManager.h"

//检测当前网络状况

AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];

//开始对网络检测

[manager startMonitoring];

[manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {

//在里面判断当前的网络情况

}];

//停止

[manager stopMonitoring];

*********************************************

#import"AFNetworking.h"

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

//进行网络请求

//因为咱们的接口问题,需要添加一个依据text/html

[manager GET:@"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/movielist.php"parameters:nilsuccess:^(AFHTTPRequestOperation *operation,idresponseObject) {

NSLog(@"%@",responseObject);

//把数据放到model

self.movieArr = [NSMutableArray array];

NSMutableDictionary *movieDic = responseObject;

for(NSMutableDictionary *dicinmovieDic[@"result"]) {

Movie *movie = [[Movie alloc]init];

[movie setValuesForKeysWithDictionary:dic];

[self.movieArr addObject:movie];

[movie release];

[self.tableview reloadData];

}

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

NSLog(@"%@",error);

}];

你可能感兴趣的:(AFN)