発生したエラー
‘stringByReplacingPercentEscapesUsingEncoding:’ is deprecated: first deprecated in iOS 9.0 – Use -stringByRemovingPercentEncoding instead, which always uses the recommended UTF-8 encoding.
翻訳
‘stringByReplacingPercentEscapesUsingEncoding:’ は非推奨です: 最初に iOS 9.0 で非推奨になりました – 代わりに -stringByRemovingPercentEncoding を使ってください、これは常に推奨 UTF-8 エンコーディングを使っています。
原因
翻訳の通りですが、
iOS 9.0 で非推奨になった‘stringByReplacingPercentEscapesUsingEncoding:’ を
stringByRemovingPercentEncoding に置き換えればOKです!
公式サイト「stringByRemovingPercentEncoding」も参考にどうぞ!
解決手順
+ (NSString *)urlDecode:(NSString *)encoded {
NSString *result = [encoded stringByReplacingOccurrencesOfString:@”+” withString:@” “];
result = [result stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
return result;
}
+ (NSString *)urlDecode:(NSString *)encoded {
NSString *result = [encoded stringByReplacingOccurrencesOfString:@”+” withString:@” “];
result = [result stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
return result;
}
参考サイト
https://qiita.com/jtemplej/items/42e50ae30214ffcd80ae
https://qiita.com/edvakf@github/items/02c02713dab05427ce22
https://m-blog-naver-com.translate.goog/PostView.naver?isHttpsRedirect=true&blogId=yesokay2&logNo=220648059207&_x_tr_sl=en&_x_tr_tl=ja&_x_tr_hl=ja&_x_tr_pto=sc