Making a search field for my browser

Discussion in 'Mac Programming' started by tominated, Dec 6, 2006.

  1. tominated macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #1
    does anybody know how to make a search field in xcode (cocoa) talk to a webkit webview objetc to make it search google? can you show me the code/connections i need to make?
     
  2. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #2
    You'd probably do something like instantiate a custom object in your nib with an IBAction called -search:, and an IBOutlet for the webview, and then hook an NSSearchField to your search method. Then you can just do something along the lines of
    Code:
     NSURL *searchURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.google.com/search?q=%@", [sender stringValue]]]; 
    to make a google search url.
     
  3. tominated thread starter macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #3
    thanks!
     
  4. tominated thread starter macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #4
    you wouldn't happen to know how to make a button toggle the search box thing from hidden to visible and back, would you?
     
  5. afornander macrumors 6502

    Joined:
    Apr 5, 2006
    #5
    dude, i recomend just LEARNING to code... if you just ask what code to copy/past every time you want to add or change in your app, you wont learn ANYTHING


    i have spoken:cool:
     
  6. tominated thread starter macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #6
    i am learning as i go along, if someone gives me a snippet of code, i try and interpret it and the pase it in to my app
     
  7. bousozoku Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #7
    If he was doing the research rather than copying and pasting code, it would help. Now, he's just learning to be dependent on others to provide him with everything.

    I know it's tougher to do the research but when one doesn't have others available, what's a person to do? Hmm...
     
  8. tominated thread starter macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
  9. bronxbomber92 macrumors regular

    Joined:
    Nov 23, 2006
    #9
    [translation]
    "What if us other programmers didn't exist? How would you learn without us here babying you with it all? What I'm trying to tell you is that we would be more willing if you were to do some independent work on yourself, and if you come across a problem, then we would help"
    [/translation]
     
  10. bousozoku Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #10
    Thanks. That's pretty much it. You've worked to learn. Why can't he?

    It's the give a man a fish, teach a man to fish story all over again.

    I'm always willing to help, but to give the answers, that's only short term help and problem solving is what a person does in software development and design.
     
  11. tominated thread starter macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #11
    ok, ok, ok. I am trying to learn, it is just i can't afford a good cocoa book (i am 13 you know). I should be getting that book by Aaron Hillegass for xmas, but until then i am going to be a complete n00b, and ask lots of questions. Anyway, my parents and my teacher say ask as many questions as you can so i can fill my brain (with a big chunk out of it because of a brain tumor) with knowlege.
     
  12. tominated thread starter macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #12
    i have realised that the *searchURL is a variable
    btw: it is saying that the variable is not used. i made a custom object with an action called search: and an outlet called searchURL, hooked it up to the search field and webview accordingly, created the header and main files, put the code you suggested in the search: action and it wont work. what have i done wrong?
     
  13. Elrond39 macrumors 6502

    Joined:
    Aug 16, 2005
    Location:
    Utrecht, The Netherlands
    #13
    I think a way around the issues that people are having with tominated can be solved easily:
    - turn it into a MacRumors "group project" of sorts, kind of small-scale open source
    - change the name to Ruminated
    - give credit where credit's due ... I like tominated's initiative, really I do, and I think that instead of arguing over his learning curve (I agree that with a book he'd learn better, but I also understand that learning practically by asking for help is useful, and f'r chrissakes, he's only 13 right? Let's cut him a little slack, by which, though, I don't mean "Give the boy a fish". How about giving him the occasional fish and guiding him in learning how to fish?), the Forum should come through and put together an awesome browser. One with awesome tab-support (a la OmniWeb?... A man can dream, and I'll settle for Shiira), a nice interface, and easy to use.

    But that's just my opinion.
     
  14. tominated thread starter macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #14
    thanks for your advice. I will make macrumors the default homepage. I don't want to change the name, but i'll have something to make it a bit more macrumorish
     
  15. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #15
    You'll need to use that URL. I just gave a rough outline, not a detailed explanation.
     
  16. tominated thread starter macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia

Share This Page