iOS 7

NSURL on iOS 7

There's a subtle change in the way URLWithString: works on devices running iOS 7. On iOS 6, spaces at the end of the string used to be percent-encoded and a valid NSURL object was created, but on iOS 7 the method will return nil. For example:

NSURL *urlOne = [NSURL URLWithString:@""];
NSURL *urlTwo = [NSURL URLWithString:@" "];


iOS7 (null)

A non-encoded space inside the string will mean nil is returned on both platforms: it's just this edge-case that is the oddity. Arguably this is actually a bug that has been fixed, and you should be encoding your strings anyway, but it's worth checking your URLs (or running stringByTrimmingCharactersInSet: over them as standard) so you don't get burned by this little beauty.