title: iOS Passing data collection view controller to a table view controller
body: <p>Hi i am doing a food app and I am having a problem. I have a collection view controller which have 10 items(each one is a different dish). Each of those items have an image and a title and what i want to do is that when someone taps the item(the dish) it takes the user to a table view controller which have a list of items(ingredients) about the dish. My problem is that I don't know how to pass the data from a collection view controller to a table view controller. Here is my code:</p>
  
  <pre><code>***View Controller.m (collection view controller):***
  
  @interface ViewController ()
  {
    NSArray *_arrayOfImages;
    NSArray *_arrayOfNames;
  
    **// Array de ingredientes**
    NSArray *_arrayOfCeviche;
    NSArray *_arrayOfBrasa;
    NSArray *_arrayOfTacacho;
    NSArray *_arrayOfPachamanca;
    NSArray *_arrayOfAnticucho;
    NSArray *_arrayOfChaufa;
    NSArray *_arrayOfPapita;
    NSArray *_arrayOfParihuela;
    NSArray *_arrayOfLomo;
    NSArray *_arrayOfCuy;
  
    **//Array which stores all the ingredients arrays**
    NSArray *_arrayOfIngredients;
  }
  @end
  
  @implementation ViewController
  
   - (void)viewDidLoad
  {
    [super viewDidLoad];
  // Do any additional setup after loading the view, typically from a nib.
  
  **// Array which contain the titles**
  _arrayOfNames = @[@"Anticucho", @"Arroz Chaufa", @"Cebiche", @"Pachamanca", @"Papa a la               Huancaina", @"Parihuela", @"Picante de cuy", @"Tacacho con cecina", @"Pollo a la brasa", @"Lomo saltado"];
  
  **// Array which containe the images**
  _arrayOfImages = @[@"Anticucho.jpg", @"chaufa.jpg", @"ceviche.jpg", @"pachamanca.jpg", @"papita.jpg", @"parihuela.jpg", @"cuy.jpg", @"tacacho.jpg", @"brasa.jpg", @"lomo.jpg"];
  
  // Arrays que de los ingredientes
  _arrayOfCeviche = @[@"Quesito", @"Limon", @"Choclito", @"Cocinita", @"La lechesita", @"La miradita", @"La weuabdita", @"La cagada", @"Ptm Toy Jodido XD", @"Que emoción", @"Wiiiiiii"];
  
  _arrayOfBrasa = @[@"jamonadita", @"delicisoso", @"Sexo", @"Anal", @"Oral", @"Vaginal", @"Culantraso", @"Violenita", @"Sexo salvaje", @"Mujeres", @"Coger coger"];
  
  _arrayOfChaufa = @[@"qUESIto", @"Jodido", @"Ala", @"Que pajita", @"Wuauau", @"Tengo hambrunita", @"jojolete", @"Sequito duro", @"Latititititito", @"Manusico"];
  
   **// Array which contains the other arrays**
  _arrayOfIngredients = @[@"_arrayOfBrasa, _arrayOfCeviche,_arrayOfChaufa];
  
  }
  
   **// Method to pass the data from a collection view controller to a table view controller**
  - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  
  if ([segue.identifier isEqualToString:@"showDetail"]) {
  
      NSIndexPath *indexPath = [[self.collectionView indexPathsForSelectedItems] objectAtIndex:0];
  
      DetailViewController *dvc = [segue destinationViewController];
      dvc.Titulos = [_arrayOfIngredients objectAtIndex:indexPath.row];
   }
  }
  </code></pre>
  
  <p>And my table view controller code:</p>
  
  <pre><code>***Detail View Controller.m (table view controller):***
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
  static NSString *CellIdentifier = @"Cell";
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  
  // Configure the cell...
  cell.textLabel.text = self.Titulos;
  
  return cell; 
  }
  </code></pre>
  
  <p>My biggest problem is the array containing the other arrays. Trying to access the _arrayOfIngredients and from it access the array of the ingredient of the selected item.</p>
  
  <pre><code>  - (void)viewDidLoad
  {
    [super viewDidLoad];
  
       **// Array which contain the titles**
        _arrayOfNames = @[@"Anticucho", @"Arroz Chaufa", @"Cebiche", @"Pachamanca", @"Papa a la Huancaina", @"Parihuela", @"Picante de cuy", @"Tacacho con cecina", @"Pollo a la brasa", @"Lomo saltado"];
  
       **// Array which containe the images**
        _arrayOfImages = @[@"Anticucho.jpg", @"chaufa.jpg", @"ceviche.jpg", @"pachamanca.jpg", @"papita.jpg", @"parihuela.jpg", @"cuy.jpg", @"tacacho.jpg", @"brasa.jpg", @"lomo.jpg"];
  
        **// Arrays que de los ingredientes**
        _arrayOfCeviche = @[@"Quesito", @"Limon", @"Choclito", @"Cocinita", @"La lechesita", @"La miradita", @"La weuabdita", @"La cagada", @"Ptm Toy Jodido XD", @"Que emoción", @"Wiiiiiii"];
  
        _arrayOfBrasa = @[@"jamonadita", @"delicisoso", @"Sexo", @"Anal", @"Oral", @"Vaginal", @"Culantraso", @"Violenita", @"Sexo salvaje", @"Mujeres", @"Coger coger"];
  
        _arrayOfChaufa = @[@"qUESIto", @"Jodido", @"Ala", @"Que pajita", @"Wuauau", @"Tengo hambrunita", @"jojolete", @"Sequito duro", @"Latititititito", @"Manusico"];
  
         **// Array which contains the other arrays**
        _arrayOfIngredients = @[@"_arrayOfBrasa, _arrayOfCeviche,_arrayOfChaufa"];
  
      }
  </code></pre>
  
  <p>Please help me with this problem :(</p>