首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xcode-9或iOS 11 -用\“not working”替换双引号

Xcode-9或iOS 11 -用\“not working”替换双引号
EN

Stack Overflow用户
提问于 2017-11-06 18:00:16
回答 1查看 206关注 0票数 0

因为我将双引号替换为转义字符,如下面代码中所述。相同的代码在iOS 10.x中运行良好,但在iOS 11中不起作用。

代码语言:javascript
复制
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]];

任何线索都将非常感谢!

提前感谢

EN

回答 1

Stack Overflow用户

发布于 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/

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47134227

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档