iOS Button open url in safari

eplefrik

macrumors newbie
Original poster
Mar 25, 2012
15
0
Hi!

This code open a url in safari on click:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mad:"http://www.apple.com"]];

But I don't know where the code should be. I tried to put in in ViewController.m below the viewDidUnload. But I can't get the button to work.

I'm new with XCode, so hope someone can help me.

Sorry for my english.
 
Last edited:

Nemox

macrumors newbie
Oct 3, 2011
7
0
What you posted is just a piece of code, you need to put it inside a method.

You would benefit a lot from reading about Objective-c
 

eplefrik

macrumors newbie
Original poster
Mar 25, 2012
15
0
What you posted is just a piece of code, you need to put it inside a method.

You would benefit a lot from reading about Objective-c
Ok, thanks! But can you give me the whole code, and where I should insert it?
 

Nemox

macrumors newbie
Oct 3, 2011
7
0
No I will not give you the whole code, what good will that do you?

You need to start in baby steps and then improve. You wont improve if you don't understand how method, Objects etc works.

So as i stated, start by learning something about the basics of the language you want to code in.

I dont say this to be a douche, but to be honest, if you skip over the basics, you will never understand how to code stuff.
 

eplefrik

macrumors newbie
Original poster
Mar 25, 2012
15
0
No I will not give you the whole code, what good will that do you?

You need to start in baby steps and then improve. You wont improve if you don't understand how method, Objects etc works.

So as i stated, start by learning something about the basics of the language you want to code in.

I dont say this to be a douche, but to be honest, if you skip over the basics, you will never understand how to code stuff.
Okey, but do you know about some good webpages where I can learn about Objective-C ?