I've got a text field in which the user can enter a URL. This is given to my app as an NSString, which of course needs to be turned into an NSURL. Traditionally what I've done has been to call -[NSString stringByReplacingPercentEscapesUsingEncoding:] on the string to turn any percent escapes the user may have typed into the raw characters, and then -[NSString stringByAddingPercentEscapesUsingEncoding:] to convert those, and any raw Unicode characters the user may have entered, back into percent escapes, resulting in a nice escaped URL string that NSURL won't choke on in its -initWithString: method.
However, in El Capitan, both -[NSString stringByReplacingPercentEscapesUsingEncoding:] and -[NSString stringByAddingPercentEscapesUsingEncoding:] are deprecated, with the suggestion to use -[NSString stringByAddingPercentEscapesWithAllowedCharacters:] instead. However, the documentation for that method says the following:
"This method is intended to percent-encode an URL component or subcomponent string, NOT the entire URL string."
So how are you supposed to encode an entire URL string? I can pretty trivially create a URL string that will make -[NSURL initWithString:] return nil if it's not escaped first.