当我用代码中的下面提到的替换带有escape char的双引号时。相同的代码在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]];
任何线索都将受到赞赏!!!!
提前致谢
答案 0 :(得分:2)
这可能是因为iOS 11中引入了智能标点符号。请查看以下链接。
https://www.reddit.com/r/apple/comments/778otd/ios_11_no_longer_encodes_double_quotes_as_the/