【发布时间】:2016-12-31 07:47:28
【问题描述】:
我有标签,我想给它两个元素的值,一个是 NSInteger,另一个是字符串
_imgIndex.text = [@(index+1) stringValue]; //how to add string here?
【问题讨论】:
标签: objective-c
我有标签,我想给它两个元素的值,一个是 NSInteger,另一个是字符串
_imgIndex.text = [@(index+1) stringValue]; //how to add string here?
【问题讨论】:
标签: objective-c
您似乎有一个整数值 (index) 和一个 Obj-C 字符串对象 (stringValue),并且您想将它们连接起来。有很多方法可以做到这一点,这里有两种:
_imgIndex.text = [NSString stringWithFormat:@"%lu%@",index,stringValue];
另一种技术是首先将整数转换为字符串,然后连接另一个字符串:
_imgIndex.text = [@(index).description stringByAppendingString:stringValue];
【讨论】: