How do I convert NSInteger to NSString datatype? How do I convert NSInteger to NSString datatype? ios ios

How do I convert NSInteger to NSString datatype?


NSIntegers are not objects, you cast them to long, in order to match the current 64-bit architectures' definition:

NSString *inStr = [NSString stringWithFormat: @"%ld", (long)month];


Obj-C way =):

NSString *inStr = [@(month) stringValue];


Modern Objective-C

An NSInteger has the method stringValue that can be used even with a literal

NSString *integerAsString1 = [@12 stringValue];NSInteger number = 13;NSString *integerAsString2 = [@(number) stringValue];

Very simple. Isn't it?

Swift

var integerAsString = String(integer)