How to add an integer into String using objective c?

2 Solutions Collect From Internet About “How to add an integer into String using objective c?”

To place an integer into a string, you can do this:

int n = 123;
NSString *s = [NSString stringWithFormat:@"This is a %d test", n];

There are numerous other ways. But concatenating strings with integers by + operator is not one of them. 🙂

To place an integer into a string, you can do this:

int number = 123;
NSString *string = [NSString stringWithFormat:@"This is a %i test", number];

Or if you want to NSLog you have to do this :

int number = 123;
NSLog(@"This is a %i test", number);

It is very EASY !!!