iOS YTKNetworking网络框架增加text/plain支持

网络请求有时候报错"Request failed: unacceptable content-type: text/plain"
解决办法: 在基类初始化时新增以下方法即可

- (void)converContentTypeConfig{
    YTKNetworkAgent *agent = [YTKNetworkAgent sharedAgent];
    NSSet *acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/plain", @"text/html", @"text/css", nil];
    NSString *keypath = @"jsonResponseSerializer.acceptableContentTypes";
    [agent setValue:acceptableContentTypes forKeyPath:keypath];
}
posted @ 2023-09-12 15:39  qqcc1388  阅读(93)  评论(0编辑  收藏  举报