I am a new iPhone programmer.
I am making a web based application. I’m taking the user input of a URL to a text box. When the button is pressed they will go to the web address.
Now when user type the URL such as http://www.google.com, then it works fine
The problem is that when user only types google.com or http://www.google.com it doesn’t work.
I don’t understand how to fix this.
If I add ‘http://’ problematically, I still have a problem because if the user writes the whole web address it will fail.
Here is my code for button click:
-(IBAction)go
{
NSMutableString *str;
str = [NSMutableString stringWithFormat:@"http://www.%@",name.text];
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
}
Here name is a textfield and webView is an object of webView. Other than the web address behavior, it works fine.
Please help….
Try this…..
-(IBAction)go
{
}
this will check “http://” , “www.” and also “.com” and handle if user did not entered any one of them….
This will work surely TRY IT……