不受支持的URL Statue Code 1002

1. 错误提示: 

Error description=Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo=0x78f97920 {NSUnderlyingError=0x79f78bd0 "unsupported URL", NSLocalizedDescription=unsupported URL}

2. 解决办法: 

URL 不能包含 ASCII 字符集中, 不是必须这样的字符进行转义的字符。

使用 stringByAddingPercentEncodingWithAllowedCharacters 字符集URLQueryAllowedCharacterSet

NSString *string = @"http://192.168.0.75:8089/api/PublishGoods/GetPublishGood?page=1&pageSize=9";

    NSString *urlString = [string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];

请参阅字符设置为 URL 编码的文档

原文地址:https://www.cnblogs.com/qyfeng009/p/5310994.html