【问题标题】:How to search for more than 1 word using a Web Service如何使用 Web 服务搜索超过 1 个单词
【发布时间】:2014-06-29 06:59:12
【问题描述】:

在我的应用程序中,您可以搜索“书籍”,Web 服务将返回廉价书籍及其所有属性的 json 数据,但如果您搜索特定书籍,如“哈利波特”,它会崩溃。我的应用程序只能处理一个单词搜索,我想知道如何进行多个单词搜索。我的网址如下所示:

NSString *urlString = [NSString stringWithFormat:@"http://us.api.invisiblehand.co.uk/v1/products?query=%@&app_id=APP_ID&app_key=APP_KEY", searchedItem.text];

感谢所有帮助,在此先感谢

【问题讨论】:

  • 崩溃是来自app还是webservice?
  • 应用程序,而不是网络服务

标签: ios objective-c xcode web-services


【解决方案1】:

试试这个:

    NSString *urlString = [NSString stringWithFormat:@"http://us.api.invisiblehand.co.uk/v1/products?query=%@&app_id=APP_ID&app_key=APP_KEY", 
     [[searchedItem.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByReplacingOccurrencesOfString:@"+" withString:@"%2B"
    ]
   ];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-01-11
    • 2011-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-29
    • 2017-08-24
    相关资源
    最近更新 更多