我正在尝试在文本标签中显示数组中的所有字符串项。
self.latestTenThrows.text = [NSString stringWithFormat:@"%@", self.savedThrowsArray];
然而,这个在 View 中的输出是:
(
"4 + 4 + 3 + 2 + 1 = 14",
"6 + 5 + 4 + 5 + 2 = 22",
"2 + 3 + 5 + 1 + 6 = 17"
)
我应该怎么做才能让它看起来像这样:
4 + 4 + 3 + 2 + 1 = 14
6 + 5 + 4 + 5 + 2 = 22
2 + 3 + 5 + 1 + 6 = 17
最佳答案
参见 Apple documentation for NSArray有一种方法可用于将所有数组元素与插入的字符串连接起来:
NSString *s = [self.savedThrowsArray componentsJoinedByString: @"\n"];
self.latestTenThrows.text = s;
关于ios - 如何分配标签文本属性以显示数组中的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21974958/