Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 2.24 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Inserting data from one table to another table
  2. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  3. {  
  4.     ActionList * actionListObj = [appDelegate.actionArray objectAtIndex:indexPath.row];  
  5.     self.chooseActions = actionListObj.actionName;
  6.     MainTableController * mainViewController = [[MainTableController alloc] init];      
  7.     [mainViewController getAction:self.chooseActions];
  8.     [self.navigationController dismissModalViewControllerAnimated:YES];
  9. }
  10.        
  11. -(void) viewWillAppear:(BOOL)animated{
  12.     [self reloadData];
  13. }
  14.  
  15. -(void) reloadData{
  16.     [self.myTableView reloadData];
  17. }
  18.  
  19. -(void) getAction: (NSString *) actionChoose{        
  20.     self.action = actionChoose;
  21.     [self reloadData];
  22. }      
  23.  
  24. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  25. {
  26.     static NSString *CellIdentifier = @"Cell";    
  27.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  28.     if (cell == nil) {
  29.         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
  30.     }
  31.     // Configure the cell...
  32.     cell.textLabel.text = self.action;
  33.     return cell;
  34. }
  35.        
  36. MainTableController * mainViewController = [[MainTableController alloc] init];
  37.        
  38. @property(readwrite, assign) MainViewController *mainViewController;
  39. // and ...
  40. @synthesize mainViewController;
  41.        
  42. // in main view controller
  43. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  44. {
  45.     // alloc/init the sub VC
  46.     subVCInstance.mainViewController = self;
  47.     [self pushViewController:subVCInstance ......
  48.        
  49. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  50. {  
  51.     ActionList * actionListObj = [appDelegate.actionArray objectAtIndex:indexPath.row];  
  52.     self.chooseActions = actionListObj.actionName;
  53.     //MainTableController * mainViewController = [[MainTableController alloc] init];      
  54.     [self.mainViewController getAction:self.chooseActions];
  55.     [self.navigationController dismissModalViewControllerAnimated:YES];
  56. }
  57.        
  58. MainTableController * mainViewController = [[MainTableController alloc] init];      
  59. [mainViewController getAction:self.chooseActions];