Alex Rivera | Logout

how to convert integer to string?

Asked 2010-08-05T12:27:38.947
38

Possible Duplicate:
How to convert from int to string in objective c: example code…

How to convert integer to string in Objective C?

Edit
Report

1 Answer

17

If you really want to use String:

NSString *number = [[NSString alloc] initWithFormat:@"%d", 123];

But I would recommend using NSNumber:

NSNumber *number = [[NSNumber alloc] initWithInt:123];

Then just add it to the array.

[array addObject:number];

Don't forget to release it after that, since you created it above.

[number release];
answered 2010-08-05T12:37:26.930

Your Answer