In my application, when the user add an object, can also add a link for this object and then the link can be opened in a webView.
I tried to save a link without http://
You can use the - (BOOL)hasPrefix:(NSString *)aString
method on NSString to see if an NSString containing your URL starts with the http:// prefix, and if not add the prefix.
NSString *myURLString = @"www.google.com";
NSURL *myURL;
if ([myURLString.lowercaseString hasPrefix:@"http://"]) {
myURL = [NSURL URLWithString:myURLString];
} else {
myURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@",myURLString]];
}
I'm currently away from my mac and can't compile/test this code, but I believe the above should work.