我有:
myAnswerArray[i]
,其中存储有四位整数,如
myAnswerArray[0]=1412
myAnswerArray[1]=0518
myAnswerArray[2]=2307
我有一个IBOutlet'answerField'
所以我想要[answerField setIntValue:(something)]
并发送:
1412 0518 2307
到文本字段。
答案 0 :(得分:2)
对于小阵列:
[answerField setStringValue:[NSString stringWithFormat:@"%04i %04i %04i", myAnswerArray[0], myAnswerArray[1], myAnswerArray[2]]];
对于较大的数组,使用NSMutableString构建字符串:
NSMutableString *temp = [NSMutableString stringWithCapacity:500];
for (int i = 0; i < 100; i++) {
[temp appendFormat:@"%04i ", myAnswerArray[i]];
}
[answerField setStringValue:temp];
答案 1 :(得分:-2)
尝试:
[answerField setStringValue:[myAnswerArray componentsJoinedByString:@" "]];