AFN拿不到cookie,无法存储cookie

跟雅思的项目对比,发现

task.currentRequest.allHTTPHeaderFields

这样不能拿到cookie

应该这样取:

NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response;
        
        NSDictionary *fileds = response.allHeaderFields;//task.currentRequest.allHTTPHeaderFields;//[operation.response allHeaderFields];
        NSURL *cookieUrl = [NSURL URLWithString:baseUrl];
        NSArray *cookieArray = [NSHTTPCookie cookiesWithResponseHeaderFields:fileds forURL:cookieUrl];

 

posted on 2018-09-12 11:57  土匪7  阅读(308)  评论(0编辑  收藏  举报