加这个方法就好了.....
- (YTKRequestSerializerType)requestSerializerType
{
return YTKRequestSerializerTypeJSON;
}
之前没说清楚 我是这样操作的 先继承YTKRequest类
@interface QH_Request : YTKRequest
@end
然后在.m文件中
#import "QH_Request.h"
@implementation QH_Request
-(NSDictionary<NSString *,NSString *> *)requestHeaderFieldValueDictionary {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSString *token = [userDefaults objectForKey:@"token"];
return @{
@"Authorization": [NSString stringWithFormat:@"Bearer %@",token],
// @"content-Type": @"application/json",
// @"charset": @"UTF-8",
// @"Cache-Control": @"no-cache",
};
}
- (YTKRequestSerializerType)requestSerializerType
{
return YTKRequestSerializerTypeJSON;
}
@end