Nsurlerrordomain code=-1002 "Unsupported URL"

Source: Internet
Author: User
Tags unsupported

I am here to implement the Community post search feature that appears when a GET request is sent, where the URL contains the search keywords and other information about the user

No results are found, but links can be opened in the browser

Error message printed in the console first, printed as follows:

Error domain=nsurlerrordomain code=-1002 "Unsupported URL"

I first read some blogs on the internet, but after trying nothing to my problem, I finally went back to the starting point to find, I found that the string I requested contains Chinese characters, the Final solution is to include one of the Chinese characters in the parameter q corresponding text encoding

[text stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]

Recompile, run, OK.

nsdictionary *dic = @{                           @ "Q":[text  stringbyaddingpercentescapesusingencoding:nsutf8stringencoding],                            @ "P0":@1,                           @ "P1": User.userid?user.userid:[uidevice  currentDevice].identifierForVendor.UUIDString,                           @ "P2": @1 ,                           @ "P3":@10,                           @ "P4":@0                            };    [requestmanager requestgetasymethod:@ "Threads"  parameters:dic  requestsucess:^ (Id object)  {        nslog (@ "%@", Object );         if ([object[@ "status"] integervalue] == 0  && object[@ "status"])         {             if ([object[@ "Threads"][@ "Rows"] isequal:[nsnull  null]])             {         &nbsp       [uiview showmessage:@ "Didn't find the topic you wanted"];                 return ;             }             NSArray *arr =  (nsarray *) object[@ "Threads"][@ "Rows"];             if (arr.count == 0)              {                 [uiview showmessage:@ "Didn't find the topic you wanted"];                 return ;             }            [ _dataarr removeallobjects];            for  (int i=0; i <[(nsarray *) object[@ "Threads"][@ "Rows"] count]; i++)  {                 nsmutablearray *array = [ nsmutablearray array];                 LocalLoginArticlesModel *model = [[LocalLoginArticlesModel alloc]  initwithdic:object[@ "Threads"][@ "Rows"][i]];                 [array addObject:model];                 [_dataArr addObject:array];             }             _tableview.arr = _dataArr;            [_tableView  reloaddata];        }    } requestfailer:^ ( Nserror *error)  {        nslog (@ "error");     }];

Read a few blog although did not solve the problem, but the page gave me inspiration, save later with

Http://stackoverflow.com/questions/24102304/nsurlerrordomain-code-1002-downloading-pdf

Nsurlerrordomain code=-1002 "Unsupported URL"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.