Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 没有http头_Objective C_Xcode_Http_Uiwebview_Nslog - Fatal编程技术网

Objective c 没有http头

Objective c 没有http头,objective-c,xcode,http,uiwebview,nslog,Objective C,Xcode,Http,Uiwebview,Nslog,我正在尝试查找http头,但我认为我的方法不起作用。 我正在使用 - (BOOL)webView:(UIWebView *)webView2 shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { NSMutableURLRequest *req = (NSMutableURLRequest *)request; NSLog(@"u

我正在尝试查找http头,但我认为我的方法不起作用。 我正在使用

- (BOOL)webView:(UIWebView *)webView2 shouldStartLoadWithRequest:(NSURLRequest *)request
 navigationType:(UIWebViewNavigationType)navigationType {

NSMutableURLRequest *req = (NSMutableURLRequest *)request;

NSLog(@"user agent = %@", [req valueForHTTPHeaderField: @"User-Agent"]);
NSLog(@"http headers = %@", [request allHTTPHeaderFields]);
NSLog(@"http headers = %@", [req allHTTPHeaderFields]);
}

但是NSLog正在打印出来

http headers = {
req和request都不是零。有人知道我为什么无法获取标题吗

谢谢
克林顿(Clinton)

出于好奇,当你试图打印一本词典时会发生什么?只是想知道,既然所有HttpHeaderFields返回的只是NSDictionary*dic=[NSDictionary Dictionary dictionaryWithContentsOfURL:[NSURL URLWithString:@http://www.google.ca]]; NSLog@dic=%@,dic;它返回为dic=null