Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easiest way to concatenate NSString and int

Is there a general purpose function in Objective-C that I can plug into my project to simplify concatenating NSStrings and ints?

like image 701
DivideByHero Avatar asked Apr 01 '09 01:04

DivideByHero


People also ask

Can I concatenate a string and integer?

To concatenate a string to an int value, use the concatenation operator. Here is our int. int val = 3; Now, to concatenate a string, you need to declare a string and use the + operator.

How do you concatenate strings and variables?

In JavaScript, we can assign strings to a variable and use concatenation to combine the variable to another string. To concatenate a string, you add a plus sign+ between the strings or string variables you want to connect. let myPet = 'seahorse'; console.

Can we concatenate string and integer in JavaScript?

In javascript, we can also concatenate strings with variables. We can do more than concatenate strings in Javascript: we can concatenate integers and booleans to strings.

Can we concatenate integer?

You can use the String concatenation operator + to concatenate integers to a string in a clear and concise manner. Note that the compiler implicitly constructs an intermediate StringBuilder object, append the integers, and then call the toString() method.


1 Answers

[NSString stringWithFormat:@"THIS IS A STRING WITH AN INT: %d", myInt]; 

That's typically how I do it.

like image 54
Genericrich Avatar answered Oct 17 '22 03:10

Genericrich