Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tominated

macrumors 68000
Original poster
Jul 7, 2006
1,723
0
Queensland, Australia
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?
 

Catfish_Man

macrumors 68030
Sep 13, 2001
2,579
2
Portland, OR
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.
 

tominated

macrumors 68000
Original poster
Jul 7, 2006
1,723
0
Queensland, Australia
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.

thanks!
 

afornander

macrumors 6502
Apr 5, 2006
286
0
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:
 

tominated

macrumors 68000
Original poster
Jul 7, 2006
1,723
0
Queensland, Australia
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:

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
 

bousozoku

Moderator emeritus
Jun 25, 2002
16,120
2,397
Lard
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:

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...
 

bronxbomber92

macrumors regular
Nov 23, 2006
109
0
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...
[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]
 

bousozoku

Moderator emeritus
Jun 25, 2002
16,120
2,397
Lard
[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]

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.
 

tominated

macrumors 68000
Original poster
Jul 7, 2006
1,723
0
Queensland, Australia
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.
 

tominated

macrumors 68000
Original poster
Jul 7, 2006
1,723
0
Queensland, Australia
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.

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?
 

Elrond39

macrumors 6502
Aug 16, 2005
282
0
Utrecht, The Netherlands
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.
 

tominated

macrumors 68000
Original poster
Jul 7, 2006
1,723
0
Queensland, Australia
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.
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
 

Catfish_Man

macrumors 68030
Sep 13, 2001
2,579
2
Portland, OR
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?

You'll need to use that URL. I just gave a rough outline, not a detailed explanation.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.