Xcode: Google searchbar in Browser?

Discussion in 'Mac Programming' started by xcoder78, Jul 9, 2007.

  1. macrumors newbie

    Joined:
    Jul 9, 2007
    #1
    Hi again, I was wondering if someone could tell me how to get a Google Search Bar in Xcode onto my Browser
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    You realise this is not a one-line of code thing. I suggest you start reading the documentation!
     
  3. macrumors 6502

    Joined:
    Aug 2, 2002
    Location:
    Éire
    #3
    Assuming your search field is an outlet in the nib file and is called "mySearchBar"

    Code:
    NSString *searchURL = [NSString stringWithFormat:@"http://www.google.com/search?q=%@", [mySearchBar stringValue]];
    Then you just load that URL in your web view.

    Code:
    [[myWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString: searchURL]]];
    This is a simple example, you can probably work from here :)
     

Share This Page