gpt4 book ai didi

ios - 如何处理搜寻字词中的空格

转载 作者:行者123 更新时间:2023-12-01 19:20:42 25 4
gpt4 key购买 nike

我正在使用以下代码段实现搜索。

-(void)getData:(NSString *)searchString
{
//Search string is the string the user keys in as keywords for the search. In this case I am testing with the keywords "epic headline"
searchString = [searchString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *resourcePath = [NSString stringWithFormat:@"/sm/search?limit=100&term=%@&types[]=users&types[]=questions&types[]=topics",searchString];

[self sendRequests:resourcePath];
}


//URL sent to server as a result
send Request /sm/search?limit=100&term=epic headline&types[]=users&types[]=questions&types[]=topics

我的搜索无法正常工作,因为它无法处理“史诗”和“标题”之间的空格。如何修改搜索词,以便可以处理间距?

最佳答案

在结果字符串上调用stringByAddingPercentEscapesUsingEncoding以根据URL规则对空格字符进行编码。

关于ios - 如何处理搜寻字词中的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10458410/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com