I am using web view in my app, getting a URL from a text field. It works if the string starts with \"http://\". I am trying to modify the code so that it can also handle the
Try This:
NSString *URL = @"apple.com" ; NSURL *newURL ; if ([URL hasPrefix:@"http://"] || [URL hasPrefix:@"https://"]) { newURL = [NSURL URLWithString:URL] ; } else{ newURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@",URL]] ; } NSLog(@"New URL : %@",newURL) ;