AFNetworking2.6代理封装--OC版

AFN-OC版

AFNetworking代理封装 用法

-(void)viewDidLoad { 

[super viewDidLoad];

[self accessToServerForGetGetLogin]; 

}

pragma mark -- 网络请求

-(void)accessToServerForGetGetLogin {

NSString *requestName = GetLoginKey;

NSString *url = @"http://apis.haoservice.com/lifeservice/cook/query?";

NSMutableDictionary *postInfo = [NSMutableDictionary dictionary];

postInfo[@"menu"] = @"土豆";

postInfo[@"pn"] = @1;

postInfo[@"rn"] = @"10";

postInfo[@"key"] = @"2ba215a3f83b4b898d0f6fdca4e16c7c";

[NetWorkRequest netWorkRequestByPostMode:url parameters:postInfo requestName:requestName delegate:self];

}

-(void)netWorkRequestSuccess:(id)data userInfo:(NSDictionary *)userInfo parameters:(NSDictionary *)getparameters { 

//服务器连接成功 NSString *requestUsername = [userInfo objectForKey:@"username"];

if ([requestUsername isEqualToString:GetLoginKey]) {

NSDictionary *dicR = (NSDictionary *)data;

NSLog(@"%@",dicR);

}

-(void)netWorkRequestFailed:(NSError*)error userInfo:(NSDictionary *)userInfo parameters:(NSDictionary *)getparameters {

 //服务器连接失败请重试 NSLog(@"%@",error); 

}

GitHub Demo下载地址:https://github.com/wzf1053132166/AFN-OC

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容