2011-12-08 52 views
0

我有此代碼 NSString * localStringValue;將一個字符串從DidSelectRowAtIndexPath傳遞到按鈕單擊操作

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
    localStringValue = [m_textfield cellForRowAtIndexPath:indexPath].textLabel.text; 
    localStringValue = [m_textfield cellForRowAtIndexPath:indexPath].detailTextLabel.text; 
    NSArray* toReload = [NSArray arrayWithObjects: indexPath, self.selectedIndexPath, nil]; 
    self.selectedIndexPath = indexPath; 
    if ([[tableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryCheckmark){ 
     UploadView *uploadview = (UploadView *)self.view; 
     if (uploadview != nil) 
     { 
      [m_owner uploadString:localStringValue]; 
      //[self dismissModalViewControllerAnimated:YES]; 
     } 

     [[m_textfield cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryNone]; 
    } 

    else { 

     [[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryCheckmark]; 

    } 
} 
在此代碼我正在同步localStringValue到谷歌文檔,當我點擊單元格,如果複選標記there.localStringValue

包含在tableview中cell.Every事工作正常,在此point.But我需要的值是我想這個值傳遞給點擊一個按鈕,這意味着如果用戶選擇多行我想在localStringValue所有值,並通過這個代碼通過這個

- (IBAction)doUpload:(id)sender 
{ 
      UploadView *uploadview = (UploadView *)self.view; 
      if (uploadview != nil) 
      { 
       [m_owner uploadString:@""]; 
       //[self dismissModalViewControllerAnimated:YES]; 
      } 

} 

我想在[m_owner uploadString:localstringvalue]; 如何localstringvalue通去做這個? 在此先感謝。

回答

0

您需要更新烏爾

- (void)doUpload:(NSString*)stringValue 
{ 
      UploadView *uploadview = (UploadView *)self.view; 
      if (uploadview != nil) 
      { 
       [m_owner uploadString:localstringvalue]; 
       //[self dismissModalViewControllerAnimated:YES]; 
      } 
} 

還有一件事 localStringValue = [m_textfield cellForRowAtIndexPath:indexPath].textLabel.text //再次重新分配字符串,因此此行沒有任何意義。

+0

它顯示錯誤「接口類型字符串不能通過值傳遞」你忘了NSString「這是我的錯誤和未聲明的本地字符串 – ICoder

1

你可以創建一個NSMutableArray作爲類變量,你可以將你的字符串添加到didSelectRowAtIndexPath上。稍後在按鈕上單擊,您可以處理NSMutableArray以逐個提取字符串並將它們發送到Google文檔...等。

+0

你可以用代碼解釋嗎?謝謝 – ICoder

相關問題