我有名为* total的NSMutableArray和名为* lblTotal的UILabel
。我从循环中得到结果值。现在,我想在UILabel
中将此值设置为viewDidLoad
。我怎样才能解决这个问题?
这是我正在使用的代码。
for(int counter = 0; counter < [node childCount]; counter++) {
if ([[[node childAtIndex:counter] name] isEqualToString:@"Total"]){
NSString *str = [[node childAtIndex:counter] stringValue];
[total addObject:str];
NSLog(@"Grand total is %@", total);
}
}
我只是想在NSString中设置结果值lbltotal.text = total。
最佳答案
NSArray *array1 = [NSArray arrayWithObjects:@"one", @"two", @"three", nil];
NSString *joinedString = [array1 componentsJoinedByString:@","];
componentsJoinedByString:
将通过指定的字符串连接数组中的组件,并返回数组的字符串表示形式。设置UILabel上的值
UILabel *label = [[UILabel alloc] init];
[label setText:joinedString];
关于iphone - 如何将NSMutableArray值转换为NSString?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17986883/