Ios 如何使用现有值在uilabel上添加值并显示它?

Ios 如何使用现有值在uilabel上添加值并显示它?,ios,Ios,我从uipickerview获取一个值,并将其设置在uitableviewcell的uilabel上,现在我想知道,如果我再次从picker视图获取值,而不是将其添加到以前的值中 以下是我的单元索引代码: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identifier = @"Cell

我从uipickerview获取一个值,并将其设置在uitableviewcell的uilabel上,现在我想知道,如果我再次从picker视图获取值,而不是将其添加到以前的值中

以下是我的单元索引代码:

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
    static NSString *identifier = @"Cell";

    UitableviewcellTableViewCell *Cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];

    if(position == indexPath.row){

    NSString *old  = Cell.nameLabel.text = value;

    int val = [old intValue];

    NSLog(@"val %d", val);



   // Cell.nameLabel.text = [NSString stringWithFormat: @"%d", val+];


   }else{
      Cell.nameLabel.text = @"value";
   }
  NSLog(@"Position :- %ld   %d", (long)indexPath.row, position);

  return Cell;
}
这是获取值的选择器视图窗体的代码

  - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
 {

    [self.mytableview reloadData];
    [self hidePickerView];
    NSLog(@"row selected:%ld", (long)row);
    value = _countingarray[row];

 }

你想在标签上附加值或添加值并显示给标签吗?我想添加值。谢谢你的回答,我想让你再次澄清我的问题。例如,我从选取器视图中选择3,当我再次单击该标签并从选取器视图中再次选择2时,它显示在uilabel上。uilabel上的值应为5。这不起作用,兄弟,cam。您建议我一些其他解决方案,请接受您的回答,它在_countingarray[行]上给出了如下错误:-“指向接口id的指针的算法,对于这个架构和平台来说,它不是一个恒定的大小”你能告诉我“计数数组”中的值吗?是的,先生,这是在选择器视图上设置值的方法:-“计数数组=@[@“1”,“2”,“3”,“4”,“5”,“3”;“我想从tableview单元格方法添加它
-(void)viewDidLoad
{
  value = @"0";
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
  NSLog(@"row selected:%ld", (long)row);
  value = [NSString stringWithFormat:@"%d",[value intval] + [_countingarray[row] intval]];
  [self.mytableview reloadData];
  [self hidePickerView];

}   


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"Cell";

    UitableviewcellTableViewCell *Cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
    Cell.nameLabel.text = value;
    NSLog(@"%@", value);
    return Cell;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    NSLog(@"row selected:%ld", (long)row);
    yourLabel.text = [yourLabel.text intVal] + [_countingarray[row] intVal];
    [self.mytableview reloadData];
    [self hidePickerView];

}