1

I don't know how to combine two NSStrings. I've a label, rohstoffe and want to set its text with two strings, but the label only shows the last string.

Why?

Here is my code:

NSString *n = @"A";
NSString *m = @"B";
self.rohstoffe.text = (@"%d und %d", n, m);
jscs
  • 63,694
  • 13
  • 151
  • 195
MacLovin1
  • 11
  • 2

2 Answers2

4
self.rohstoffe.text = [NSString stringWithFormat:@"%@ und %@", n, m];

%@ is for strings and pointers %i and %d are for integers and %f is used for floats and double. This should cover you for most stuff. These are the same symbols used for NSLog. A full list can be found here

Justin Meiners
  • 10,754
  • 6
  • 50
  • 92
0

You are assigning only the first parameter of your expression. Try this:

self.rohstoffe.text = [NSString stringWithFormat:@"%d und %d", n, m];
Eimantas
  • 48,927
  • 17
  • 132
  • 168