因为我将双引号替换为转义字符,如下面代码中所述。相同的代码在iOS 10.x中运行良好,但在iOS 11中不起作用。
NSString *searchStr = [searchBar.text stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
NSString *searchInput = [[NSString alloc] initWithFormat:@"{\"@type\": \"com.xyz.rest.find.SearchQuery\",\"value\": \"%@\"}", searchStr];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[searchInput dataUsingEncoding:NSUTF8StringEncoding]];任何线索都将非常感谢!
提前感谢
发布于 2017-11-08 17:50:42
这可能是因为iOS 11中引入了智能标点符号。请检查下面的链接。
https://www.reddit.com/r/apple/comments/778otd/ios_11_no_longer_encodes_double_quotes_as_the/
https://stackoverflow.com/questions/47134227
复制相似问题