gpt4 book ai didi

objective-c - stringByAddingPercentEscapesUsingEncoding 弃用

转载 作者:行者123 更新时间:2023-12-05 03:09:32 24 4
gpt4 key购买 nike

这已弃用“stringByAddingPercentEscapesUsingEncoding”,我想用更新一替换这一行。

NSString *encodedString = [modalData.imageURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

最佳答案

尝试下面的代码行:

NSString *encodedString = [modalData.imageURL stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];

stringByAddingPercentEncodingWithAllowedCharacters:

Returns a new string made from the receiver by replacing all characters not in the specified set with percent encoded characters.

字符集被传递给 - stringByAddingPercentEncodingWithAllowedCharacters:

+ (NSCharacterSet *)URLUserAllowedCharacterSet;
+ (NSCharacterSet *)URLPasswordAllowedCharacterSet;
+ (NSCharacterSet *)URLHostAllowedCharacterSet;
+ (NSCharacterSet *)URLPathAllowedCharacterSet;
+ (NSCharacterSet *)URLQueryAllowedCharacterSet;
+ (NSCharacterSet *)URLFragmentAllowedCharacterSet;

引用:https://developer.apple.com/reference/foundation/nsstring/1411946-stringbyaddingpercentencodingwit

关于objective-c - stringByAddingPercentEscapesUsingEncoding 弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42529509/

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