startuprob
startuprob

Reputation: 1915

iPhone Linking to an iTunes page

I found a page (http://itunes.apple.com/linkmaker) to get the iTunes url for a specific page which I assume should direct the user out of my app and into the corresponding page in the app store.

I have never done this or any other UIWebView stuff but after some searching I found some code that I thought would work that uses UIApplication.h.

My code is:

#import <UIApplication.h>

//...in a tableView....
case 8:
- (BOOL)openURL:(NSURL *) http://itunes.apple.com/us/app/lockbox-pro/id288460603?mt=8&uo=4;
break;

openURL has an error saying that it is undeclared - but I imported the UIApplication.h file. Then I saw that the UIApplication import also had an error on it. I don't think that I want to use UIWebView because from what I understand, that opens up the URL in the app itself - I want to direct the user to the App Store. Where am I going wrong?

EDIT: Okay, I changed it to a simple button that is supposed to close the app and bring the user to the itunes page:

- (IBAction) pressedFull {
[[UIApplication sharedApplication] openURL:[NSURL urlWithString:@"http://www.google.com"]];

}

I linked it in IB - it still crashes the app when the user clicks on it.

Upvotes: 0

Views: 310

Answers (1)

Joshua Nozzi
Joshua Nozzi

Reputation: 61228

Your code has a number of things wrong in just one line. First, you're typing the method signature rather than using the method properly (ie, sending a message to an object). Second, you're not enclosing the string.

Try this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://yoururlhere"]];

With respect, you should review the Learning Objective-C: a Primer thoroughly until you are more comfortable with the syntax as well. A quick look at some of your other questions suggests this is your biggest issue. You'll be doing yourself a huge favor by setting all else aside and concentrating on getting Objective-C well and truly under your belt before continuing.

Upvotes: 5

Related Questions