AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];
GET\POST请求
- (AFHTTPRequestOperation*)GET:(NSString *)URLString
parameters:(id)parameters
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
- (AFHTTPRequestOperation*)POST:(NSString *)URLString
parameters:(id)parameters
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
文件上传
- (AFHTTPRequestOperation*)POST:(NSString *)URLString
parameters:(id)parameters
constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
监控联网状态
AFNetworkReachabilityManager*manager = [AFNetworkReachabilityManager sharedManager];
[manager startMonitoring];
[manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatusstatus) {
NSLog(@"%d",status);
}];
提示:要监控网络连接状态,必须要先调用单例的 startMonitoring方法