PDA

View Full Version : Help with displaying integers




iphonedevelop18
Mar 3, 2009, 12:51 AM
int number = 20;

NSString *labelText = [[NSString alloc] initWithFormat:@"%f", number];
label.text = labelText;
[labelText release];

how would I make the text output the integer, it worked with a slider to output the "slider.value" so now i cant get it to output the integer. I think is has something to do with the @"%f" because when you output a string, you use @"%@d".



caveman_uk
Mar 3, 2009, 02:34 AM
Use %i for integers

dejo
Mar 3, 2009, 08:51 AM
...because when you output a string, you use @"%@d".
No, you should be using %@ for strings.

caveman_uk
Mar 3, 2009, 08:57 AM
I just assumed the OP was a bad typist and let that one go....:D

dejo
Mar 3, 2009, 09:07 AM
I just assumed the OP was a bad typist and let that one go....:D
Based on this thread and others started by the OP, I'm afraid it's more than just bad typing. They don't seem to have a good grasp of even the basics of Objective-C. I feel they would be best served if they stepped back and did some reading and learning about the language and its usage.

iphonedevelop18
Mar 3, 2009, 01:36 PM
Thank you for helping me, sorry for asking so many questions, If you could I would like a website that would help me more understand objective c as I have only programmed in a variation of c for robots and other languages.

caveman_uk
Mar 4, 2009, 02:31 AM
The thing is that the question in this thread and in the other one about maths functions are basic bog-standard C. They're not specific to objective C.