0

I have label and I want to give it value of two elements that one of them NSInteger and the other string

_imgIndex.text = [@(index+1) stringValue]; //how to add string here?
Denis Windover
  • 445
  • 2
  • 6
  • 20

1 Answers1

1

It appears that you have an integer value (index) and a Obj-C string object (stringValue) and you want to concatenate them. There are lots of ways of doing this, here are two:

_imgIndex.text = [NSString stringWithFormat:@"%lu%@",index,stringValue];

The other technique would be to first convert the integer into a string, then concatenate the other string:

_imgIndex.text = [@(index).description stringByAppendingString:stringValue];

James Bucanek
  • 3,299
  • 3
  • 14
  • 30