相关疑难解决方法(0)

如何在JSONRequestOperation上向AFNetworking添加自定义标头

嗨,我有以下访问URL的代码:

NSString * stringURL = [NSString stringWithFormat:@"%@/%@/someAPI", kSERVICE_URL, kSERVICE_VERSION];
NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:stringURL]];

AFJSONRequestOperation * operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    completionHandler(JSON, nil);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
    completionHandler(nil, error);
}];
Run Code Online (Sandbox Code Playgroud)

但我想将用户令牌作为参数传递HEADER,如X-USER-TOKEN.

无法找到它AFNetworking documentation,我应该更改操作类型吗?

json objective-c nsurlrequest ios afnetworking

19
推荐指数
3
解决办法
3万
查看次数

标签 统计

afnetworking ×1

ios ×1

json ×1

nsurlrequest ×1

objective-c ×1