//
// ViewController.m
// UI-NO-22网络编程第三方
//
// Created by Bruce on 15/8/24.
// Copyright (c) 2015年 Bruce. All rights reserved.
//
#import "ViewController.h"
#import "AFNetworking.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
/*
// 使用 AFNetWorking 自带的类 判断网络状态
// 初始化AFNetworkReachabilityManager
AFNetworkReachabilityManager *manager =[AFNetworkReachabilityManager sharedManager];
[manager startMonitoring];
NSLog(@"%ld",manager.networkReachabilityStatus);
// 网络状态 发生改变 调用
[manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case AFNetworkReachabilityStatusUnknown: {
NSLog(@"未知的网络状态");
break;
}
case AFNetworkReachabilityStatusNotReachable: {
NSLog(@"没有网络");
break;
}
case AFNetworkReachabilityStatusReachableViaWWAN: {
NSLog(@"蜂窝数据网络");
break;
}
case AFNetworkReachabilityStatusReachableViaWiFi: {
NSLog(@"WIFI");
break;
}
default: {
break;
}
}
}];
*/
// get
// GET URL 字符串 地址 parameters body体的内容
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"" parameters:nil success:^(AFHTTPRequestOperation * operation, id responseObject) {
// responseObject 请求下来的数据内容
} failure:^(AFHTTPRequestOperation * operation, NSError * error) {
}];
/*
// post
// parameters 需要 post 的内容
[manager POST:@"" parameters:@{} success:^(AFHTTPRequestOperation * operation, id responseObject) {
} failure:^(AFHTTPRequestOperation * operation, NSError * error) {
}];
*/
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end