Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert integer to string? [duplicate]

Tags:

objective-c

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

How to convert integer to string in Objective C?

like image 229
Ranjeet Sajwan Avatar asked Aug 05 '10 12:08

Ranjeet Sajwan


People also ask

Can int be casted to double?

We can convert int value to Double object by instantiating Double class or calling Double. valueOf() method. Let's see the simple code to convert int to Double in java.


1 Answers

NSArray *myArray = [NSArray arrayWithObjects:[NSNumber numberWithInt:1], [NSNumber numberWithInt:2], [NSNumber numberWithInt:3]]; 

Update for new Objective-C syntax:

NSArray *myArray = @[@1, @2, @3]; 

Those two declarations are identical from the compiler's perspective.

if you're just wanting to use an integer in a string for putting into a textbox or something:

int myInteger = 5; NSString* myNewString = [NSString stringWithFormat:@"%i", myInteger]; 
like image 113
peelman Avatar answered Nov 04 '22 09:11

peelman