title: How to save selected rows from UITableview to NSString variable?
body: <p>I am new to xcode and making my first iPhone app.</p>
  
  <p>I have a <code>UITableview</code> with 8 rows in a tabbed screen. I have a code which let's the user select maximum 4 rows at a time and mark it with checks when selected. </p>
  
  <p>Now, when I change the view and navigate to the next tab I want to save the text from these checked rows in a single <code>NSString</code> variable separated by commas. </p>
  
  <p>Is it possible to do so? Thank you, any help is very much appreciated.</p>
  
  <p>Here is the code of the first tab from where I want to save the selected rows.</p>
  
  <pre><code>@implementation Psychological
  
  static int count = 0;
  - (void)viewDidLoad {
  [super viewDidLoad];
  
  listOfItems = [[NSMutableArray alloc] init];
  
  [listOfItems addObject:@"1 option"];
  [listOfItems addObject:@"2 option"];
  [listOfItems addObject:@"3 option"];
  [listOfItems addObject:@"4 option"];
  [listOfItems addObject:@"5 option"];
  [listOfItems addObject:@"6 option"];
  [listOfItems addObject:@"7 option"];
  [listOfItems addObject:@"8 option"];    
  
  }
  #pragma mark -
  #pragma mark Table view data source
  
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  // Return the number of sections.
  return 1;
  }
  
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section     {
  // Return the number of rows in the section.
  return [listOfItems count];
  }
  
  
  // Customize the appearance of table view cells.
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
  static NSString *CellIdentifier = @"Cell";
  
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell == nil) {
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
  }
  
  
  // Configure the cell...
  NSString *cellValue = [listOfItems objectAtIndex:indexPath.row];
  cell.text = cellValue;
  
  
  
  return cell;
  }
  
  
  #pragma mark -
  #pragma mark Table view delegate
  
  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  
  UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
  if ([selectedCell accessoryType] == UITableViewCellAccessoryNone) {
      if(count &lt; 4)
      {
      [selectedCell setAccessoryType:UITableViewCellAccessoryCheckmark];
      [selectedIndexes addObject:[NSNumber numberWithInt:indexPath.row]];
          count++;
      }
  
  } else {
      [selectedCell setAccessoryType:UITableViewCellAccessoryNone];
      [selectedIndexes removeObject:[NSNumber numberWithInt:indexPath.row]];
      count --;
  }
  [tableView deselectRowAtIndexPath:indexPath animated:NO];
  
  }
  
  
  - (void)dealloc {
  
  [listOfItems release];
  [super dealloc];
  }
  
  
  @end
  </code></pre>