真真好久沒有寫博客了铛碑。
Method Swizzling的介紹見女神博客:
http://blog.csdn.net/yiyaaixuexi/article/details/9374411
YTKNetWorking 見:
https://github.com/yuantiku/YTKNetwork?utm_source=tuicool
YTKNetWorking有個(gè)配置網(wǎng)絡(luò)請(qǐng)求的類叫YTKNetworkAgent,在其中
_manager = [AFHTTPRequestOperationManager manager];
這個(gè)方法是非公開的虽界。
而實(shí)際應(yīng)用中汽烦,會(huì)需要改變網(wǎng)絡(luò)請(qǐng)求的一些配置,所以考慮用Method Swizzling去處理:
//AFNet支持text.
YTKNetworkAgent *agent = [YTKNetworkAgent sharedInstance];
[agent setValue:[NSSet setWithObjects:@"application/json", @"text/plain", @"text/javascript", @"text/json",@"text/html",@"text/css", nil] forKeyPath:@"_manager.responseSerializer.acceptableContentTypes"];
//AFNet支持Https 測(cè)試環(huán)境下忽略https證書莉御。。
[agent setValue:@YES forKeyPath:@"_manager.securityPolicy.allowInvalidCertificates"];
簡(jiǎn)書已經(jīng)棄用迄薄,歡迎移步我的小專欄:
https://xiaozhuanlan.com/dahuihuiiOS