How can i build a NSString variable consisting of string and float variables?
I assume i need to cast the floats to strings, but i cant see how this is done without creating alot of messy and ugly code.
I want to build something like this: String+ Float+ String+ Float
Thanks in advance.
That is not how Objective C works. In Java, you would use:
You cannot do the same in Objective C. To do something to the same effect, you would need:
This would result in the equivalent to the Java statement.
%@indicates you want to format an object into the string, and%findicates a floating point value.When formatting floats in an NSString, you can specify how many decimal places you want to truncate to by placing a value in between the
%andf. For example, to round the first float to 2 decimal places and the second one to 5 decimal places: