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?
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?
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];