Hello.
I've created a Cocoa document based web browser containing a web view and textfield and am trying to program it to check to see if the user entered "http://" in the URL textfield. If the user didn't enter http, add it to the address and load that page, otherwise just load the user's URL.
I have an action set up:
Originally, it contained the following:
With urlString being the File's Owner output.
My initial thought was to somehow check urlString to see if "http://" was located in there. Unfortunately, I'm not sure how to accomplish this. I read somewhere that I should use rangeOfString to do this, but I'm not understanding how I would implement that.
Going further, I thought that once I check to see if the input URL contains http I would use a conditional statement to either add "http://" to the URL and then load the revised URL, or load the URL located in the textfield if it already contains "http".
Could someone walk me through this a little bit, just to get me started on the right track and provide some examples I could follow along with?
Thank you very much!
I've created a Cocoa document based web browser containing a web view and textfield and am trying to program it to check to see if the user entered "http://" in the URL textfield. If the user didn't enter http, add it to the address and load that page, otherwise just load the user's URL.
I have an action set up:
Code:
-(IBAction)connectURL:(id)sender {
Code:
[urlString setStringValue:[sender stringValue]];
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[sender stringValue]]]];
With urlString being the File's Owner output.
My initial thought was to somehow check urlString to see if "http://" was located in there. Unfortunately, I'm not sure how to accomplish this. I read somewhere that I should use rangeOfString to do this, but I'm not understanding how I would implement that.
Going further, I thought that once I check to see if the input URL contains http I would use a conditional statement to either add "http://" to the URL and then load the revised URL, or load the URL located in the textfield if it already contains "http".
Could someone walk me through this a little bit, just to get me started on the right track and provide some examples I could follow along with?
Thank you very much!