How do I convert NSInteger to NSString datatype?

senthilMuthu picture senthilMuthu · Nov 25, 2009 · Viewed 152.3k times · Source

How does one convert NSInteger to the NSString datatype?

I tried the following, where month is an NSInteger:

  NSString *inStr = [NSString stringWithFormat:@"%d", [month intValue]];

Answer

luvieere picture luvieere · Nov 25, 2009

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];