4

これは iOS 8 でのみ表示されます。以前のバージョンでは問題ありません。

例:

iOS 7.1 の場合:

NSString *url = @"http://www.example.com/api/search?name=test&page=1";
NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] init];
[urlRequest setURL:[NSURL URLWithString:url]];

urlRequestとして取得

<NSMutableURLRequest: 0x7b787130> { URL: http://www.example.com/api/search?name=test&page=1 }

iOS 8.0 の場合:

NSString *url = @"http://www.example.com/api/search?name=test&page=1";
NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] init];
[urlRequest setURL:[NSURL URLWithString:url]];

urlRequestとして取得

<NSMutableURLRequest: 0x7b6246d0> { URL: http://www.example.com/api/search?name=test&page=1, headers: (null) }

iOS 8.0 のエラー:Error 400 (Bad Request)

4

1 に答える 1

0

あなたはそのログを誤解しています。それはちょうどそれを意味します

URL = "http://www.example.com/api/search?name=test&page=1"

headers = null

デバッグする必要があるのは、実際のヘッダーです。

NSLog("%@", urlRequest.allHTTPHeaderFields);
于 2014-09-22T10:27:07.503 に答える