Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-26-2009, 05:30 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 66
Question Opening Link in Safari Problem

I am trying to open a link in safari and I know how to do it, but I am running into some problems.

HTML Code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"%@", link]];
this seems like it should work, but for some reason i get the following error:

Too many arguments to function 'URLWithString:'

help is appreciated
mikelowe is offline   Reply With Quote
Old 12-27-2009, 12:54 AM   #2 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,578
Default

You don't need the @"%@" before the link. You only use that when you are using a format string.
JasonR is online now   Reply With Quote
Old 12-27-2009, 12:57 AM   #3 (permalink)
David Porter Apps
 
bobbypage's Avatar
 
Join Date: Aug 2009
Posts: 71
Default

Why don't you just do it like this?
Code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];
__________________
Check out my website/blog: http://www.davidporterapps.com

Follow Me on Twitter:
http://twitter.com/bobbypage
bobbypage is offline   Reply With Quote
Old 12-27-2009, 01:21 AM   #4 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 66
Default

Quote:
Originally Posted by bobbypage View Post
Why don't you just do it like this?
Code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];
Because the eventually the user will be defining the link so it cant be one definite url.
mikelowe is offline   Reply With Quote
Old 12-28-2009, 06:59 PM   #5 (permalink)
Registered Member
 
Join Date: Feb 2009
Location: Belgium
Posts: 106
Default

URLWithString only takes one argument, you gave it two. You're trying to format the string, so this is what you need:
Code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", link]]];
SkyTrix is offline   Reply With Quote
Old 12-28-2009, 07:55 PM   #6 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 471
Default

or you could do

Code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:link]];
i think
__________________
01010111 01101111 01110111 00101100 00100000 01001010 01110101 01110011 01110100 01101001 01101100 01101100 00110100 00110101 00101100 00100000 01111001 01101111 01110101 01110010 00100000 01110011 01101111 01101111 01101111 00100000 01100011 01101111 01101111 01101111 01101100
WillSDev is offline   Reply With Quote
Reply

Bookmarks

Tags
error, link, opening, safari

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 257
17 members and 240 guests
@sandris, ADY, Alsahir, dacapo, Dani77, Desert Diva, djohnson, HemiMG, jansan, JasonR, MarkC, mer10, prchn4christ, ryandb2, smethorst, tomtom100
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:59 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0