Click here to Skip to main content
14,240,836 members
Rate this:
Please Sign up or sign in to vote.
See more:
this is my code textbox1 is the NStextfeild

NSString *searchURL = [NSString stringWithFormat:@"https://www.google.com.au/webhp?sourceid=chrome-instant&ion=1&ie=UTF-8#hl=en&safe=off&tbo=d&sclient=psy-ab&q=", [_textbox1 stringValue]];


and this is my error
<br />
data argument is not used for format string<br />


ive searched all around the web for this and basically I only get information on xcode 4 and lower, which is useless because wee up to xcode 6 now for ios 6.1

so basically I have a button where this code is connected to, i press the button and it goes to the google site + whatever you typed in the textbox

sounds simple, its not, can some one please help me with this? and please don't tell me to go learn the basics of xcode programming, because I only learn from making small projects like this.
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

See the NSString +stringWithFormat: documentation.

In particular, look at the "Formatting String Objects" examples and the "String Format Specifiers" documentation.

You either need to change your format string to:

NSString *searchURL = [NSString stringWithFormat:@"https://www.google.com.au/webhp?sourceid=chrome-instant&ion=1&ie=UTF-8#hl=en&safe=off&tbo=d&sclient=psy-ab&q=%@", [_textbox1 stringValue]];


Or you could just say:

NSString *searchURL = @"https://www.google.com.au/webhp?sourceid=chrome-instant&ion=1&ie=UTF-8#hl=en&safe=off&tbo=d&sclient=psy-ab&q=";

searchURL = [searchURL stringByAppendingString: [_textbox1 stringValue]];
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100