Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert NSNumber to NSString

Try:

NSString *myString = [NSNumber stringValue];

You can do it with:

NSNumber *myNumber = @15;
NSString *myNumberInString = [myNumber stringValue];

//An example of implementation :
// we set the score of one player to a value
[Game getCurrent].scorePlayer1 = [NSNumber numberWithInteger:1];
// We copy the value in a NSNumber
NSNumber *aNumber = [Game getCurrent].scorePlayer1;
// Conversion of the NSNumber aNumber to a String with stringValue
NSString *StringScorePlayer1 = [aNumber stringValue];

or try NSString *string = [NSString stringWithFormat:@"%d", [NSNumber intValue], nil];