The reason it doesn't work is because those are not directly legal characters for a URL.
This is taken from a brilliant answer to an (in effect) related Question on SO: Which characters make a URL invalid?
"In general URLs as defined by RFC 3986 (see Section 2: Characters) may contain any of the following characters: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=. Any other character needs to be encoded with the percent-encoding (%hh). Each part of the URI has further restrictions about what characters need to be represented by an percent-encoded word."
However in practice, you shouldn't really use commas or square brackets or funky things in a URL - you don't know which browsers will deal with it properly or not. There is absolutely no good reason to use any funky characters in a URL - even if it is a URL to a local file.
Yes, using NSURL URLWithString
is a better policy for Objective-C, but the main thing to do is stick to the dos and don'ts of URLs.