Robb
Robb

Reputation: 53

Using UITextField and UIButton to launch a Google search in Safari

I am just finishing up the last part of my app, and I have done something similar before, but I took a pretty long break in coding and forgot.

What I'm trying to do is have the user enter a string in the UITextField and then have that added to a search string and opened in Safari.

Ideas appreciated!

Upvotes: 0

Views: 530

Answers (3)

Karthikeyan
Karthikeyan

Reputation: 1790

Robb - Try this

NSString *searchString = @"iPhone"; // UItextField.text

NSString *finalString = [NSString stringWithFormat:@"http://www.google.com/search?q=%@",searchString];

[[UIApplication sharedApplication]openURL:[NSURL URLWithString:finalString]];

this will launch safari with search results of google.

Upvotes: 1

visakh7
visakh7

Reputation: 26400

You can make use of this

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urUrlString]];

Upvotes: 0

Praveen S
Praveen S

Reputation: 10393

Create the url and open it as a shared application. If you don't want to exit your app then you can probably open the url in a uiwebview.

Upvotes: 0

Related Questions