How to display integer?

Member
Posts: 24
Joined: 2008.11
Post: #1
Hello!
I'm wondering how to display an integer.

Should i convert the integer into a string which i display?

How do I do that? What code?

Kind regards
lightlab
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
Quote this message in a reply
Member
Posts: 43
Joined: 2009.04
Post: #3
Create a label and use this code

Code:
    labelsName.text = [NSString stringWithFormat:@"%d", integersName];
Hope this helps
Chris
Quote this message in a reply
Member
Posts: 24
Joined: 2008.11
Post: #4
I got this code working:

NSString *s = [NSString stringWithFormat:@"%i", integersName];
[s drawAtPoint:CGPointMake(320/2,480/2) withFont:[UIFont systemFontOfSize:[UIFont systemFontSize]]];


But its displayed upside down! Sad

How do i fix that?
Quote this message in a reply
Member
Posts: 51
Joined: 2009.02
Post: #5
I have the digits handy as textures for drawing and I use a numeric to array of digits function that looks like this:

unsigned numberToDigits(unsigned num) {
unsigned digits;

digits = 0;
do {
digit[digits++]=num % 10;
num /= 10;
} while (num > 0);
return digits;
}
Quote this message in a reply
Member
Posts: 51
Joined: 2009.02
Post: #6
lightlab Wrote:I got this code working:

NSString *s = [NSString stringWithFormat:@"%i", integersName];
[s drawAtPoint:CGPointMake(320/2,480/2) withFont:[UIFont systemFontOfSize:[UIFont systemFontSize]]];


But its displayed upside down! Sad

How do i fix that?

Turn your iPhone upside down!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Define Random Integer (Best Way) 9livesoftware 2 3,168 Sep 24, 2009 11:09 PM
Last Post: Bachus