#import “AFNetworking.h”
AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
[manager GET:@"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/movielist.php" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.movieArr =[NSMutableArray array];
NSMutableDictionary *dic =responseObject;
for (NSMutableDictionary *temp in dic[@"result"]) {
Movie *movie =[[Movie alloc] init];
[movie setValuesForKeysWithDictionary:temp];
[self.movieArr addObject:movie];
}
[self.movieTableView reloadData];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
AFNetworkReachabilityManager *manager=[AFNetworkReachabilityManager sharedManager];
[manager startMonitoring];
[manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
// 在里面判断当前的网络情况
if (status == 0) {
NSLog(@"未连接");
}else if(status == 1){
NSLog(@"2G/3G网络");
}else if(status == 2){
NSLog(@"wifi");
}else{
NSLog(@"未知网络");
}
}];
[manager stopMonitoring];
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/mltianya/article/details/47829397