使用AFNetworking&MJExtension进行数据请求

AFHTTPSessionManager *manger = [AFHTTPSessionManager manager];

manger.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/html",@"text/json", @"text/javascript", nil];

NSString *url = @"http://app.95e.com/vm/getMenu.aspx?";

NSDictionary *xqDict = @{

@"i":self.xqId;

};

[manger GET:url parameters:xqDict progress:^(NSProgress * _Nonnull downloadProgress) {

} success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

self.xxModel = [XXModel mj_objectWithKeyValues:[responseObject objectForKey:@"data"]];

[self.tableView reloadData];

} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

}];

}

声明我这个Model装的全是这种数据,自动转换成模型

+ (NSDictionary*)mj_objectClassInArray{

return @{

@"data":@"XQModel",

};

}

更换数据的名字

+ (NSDictionary *)mj_replacedKeyFromPropertyName{

return @{

@"des":@"description",

};

}

你可能感兴趣的:(使用AFNetworking&MJExtension进行数据请求)