Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

subsonix

macrumors 68040
Original poster
Feb 2, 2008
3,551
79
Hi,

I have some problems with using a variable as argument with the startSpeakingString method. The variable is an integer and the expression looks like this:

[myObject startSpeakingString: @"%i", variable];

When I do like this I get a "too many arguments" error and if I put a parantes around the string and variable I get a "…makes pointer from integer without a cast" warning.

I have tried to add NSLog(@"%i", variable); and it works as expected.

Any Ideas what I might be doing wrong here?
 

BigJimSlade

macrumors member
Dec 16, 2005
38
0
Try:

Code:
[myObject startSpeakingString: [NSString stringWithFormat:@"%i", variable]];
startSpeakingString wants an NSString, and you were passing a static NSString and an int. To get the "printf" effect you're after, you need to use the factory methods NSString provides.

I.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.