EDIT:
This is probably an undocumented but supposed behavior. See - is this `addPercentEncoding` broken in Xcode 9 beta 2? for more details.
This is mistake.
I went into different cases, it seems that all Swift code is working correctly. Please note that : allowed in the URL, so it should not be encoded and the error is in the Obj-C version .
NSCharacterSet *set = [NSCharacterSet URLHostAllowedCharacterSet]; NSLog(@"Colon is member: %@", [set characterIsMember:':'] ? @"true" : @"false");
This is an interesting mistake, because if you add ":" to the character set manually
NSMutableCharacterSet *set = [[NSCharacterSet URLHostAllowedCharacterSet] mutableCopy]; [set addCharactersInString:@":"];
Everything starts to work correctly.
Report this.
Please note that when encoding URL parameters you should not use urlHostAllowed . If possible, use NSURLQuery to create the URL . None of the predefined sets are actually suitable for encoding URLs. You can start with urlQueryAllowed , but you still have to remove a few characters from it.
See for example this answer for the correct solution or, for example, for implementation in the Alamofire library .
source share