I'm a junior developer, and I got a code for this:
(NSString *)encodedStringFromObject:(id)object { return [[object description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; }
But in 9.0 have to use stringByAddingPercentEncodingWithAllowedCharacters
.
How Could I transfer this code ? I need help, Thanks!
If you want just fast example look at this code:
NSString * encodedString = [@"string to encode" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
Also check List of predefined characters sets
If you want explanation read the documents or at least this topic: How to encode a URL in Swift
URL = [[NSString stringWithFormat:@"%@XYZ",API_PATH]stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With