Get cookies from NSHTTPURLResponse

前端 未结 5 913
忘掉有多难
忘掉有多难 2020-12-16 20:02

I\'ve an extremely weird problem, I\'m requesting a URL and I want to get the cookies from it, I\'ve used this way to get the cookies:

- (void)connection:(NS         


        
5条回答
  •  抹茶落季
    2020-12-16 20:32

    Did you tried following code sample, it should work:

    - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
    {
        NSArray *cookies =[[NSArray alloc]init]; 
        cookies = [NSHTTPCookie 
            cookiesWithResponseHeaderFields:[response allHeaderFields] 
            forURL:[NSURL URLWithString:@""]]; // send to URL, return NSArray
    }
    

提交回复
热议问题