加這個方法就好了.....
- (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