Apple has made several subtle changes related to case (as in upper/lower/mixed-case) in the URL and HTTP communication classes for iOS 5. Here’s the first one, and more blog posts to follow.
With a UIWebView I often implement the shouldStartLoadWithRequest method in the UIWebViewDelegate to look at the link the user tapped and take specific action for certain types of links. Here’s a simple example that handles mailto links:
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
BOOL shouldStartLoadWithRequest = YES;
NSString *scheme = [[request URL] scheme];
if ([scheme isEqualToString:@"mailto"]) {
[[UIApplication sharedApplication] openURL:[request URL]];
shouldStartLoadWithRequest = NO;
}
return shouldStartLoadWithRequest;
}
Another common use is to handle application specific links like “MyApp://goto?id=42″. If you just replaced @”mailto” with @”MyApp” in the example code above, it turns out that this breaks in iOS 5. The reason is that iOS 5 returns “myapp” (all lowercase) for the scheme, whereas iOS 4 and earlier returned the actual string from the HTML link unaltered.
The solution is simple. Just make your string comparison case insensitive. For example:
if ([scheme compare:@"MyApp" options:NSCaseInsensitiveSearch] == NSOrderedSame) {