标签:
SURLRequest*request =[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/"]]; NSURLConnection*connection =[NSURLConnection connectionWithRequest:request delegate:self]; -(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response { NSHTTPURLResponse*HTTPResponse=(NSHTTPURLResponse*)response; NSDictionary*fields =[HTTPResponse allHeaderFields]; NSString*cookie =[fields valueForKey:"Set-Cookie"];// It is your cookie } //保存好Cookie,当另一个request要用到这个cookies时,用如下方法加入: NSMutableURLRequest*request =[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/"]]; [request addValue:cookie forHTTPHeaderField:"Cookie"];
标签:
原文地址:http://www.cnblogs.com/letMalikelyo/p/5269202.html