我试图打印出一个包含"性格,如:
NSString *wrapAccessToken = [NSString stringWithFormat:@"WRAP access_token=\"%@", securityToken];
哪个应打印出静态字符串,引号字符,然后打印出securityToken中包含的字符串。但相反,它打印出WRAP access_token = \"。为什么要打印转义字符\?它正被添加到http标头中,我使用AFNetworking 2.0,并返回错误400.完全错误:
错误:错误域= NSCocoaErrorDomain代码= 3840"操作无法完成。 (可可误差3840。)" (字符0周围的值无效。)UserInfo = 0x10c0aca70 {NSDebugDescription =字符0周围的值无效,NSUnderlyingError = 0x10c0abc90"请求失败:错误请求(400)"}
代码在这里:
NSString *securityToken = [keychainItem objectForKey:(__bridge id)(kSecAttrAccount)];
NSString *wrapAccessToken = [NSString stringWithFormat:@"WRAP access_token=\"%@", securityToken];
[request addValue:wrapAccessToken forHTTPHeaderField:@"Authorization"];
NSLog(@"request: %@ %@", request.description, request.allHTTPHeaderFields);
NSLog打印出以下内容进行授权:(令牌缩短,额外的斜杠在开头)
Authorization = "WRAP access_token=\"http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=WwD3j3G0hn141agd";
为什么要打印出来?是\ 400错误的原因,还是我应该在其他地方看看?