ketokun
ketokun

Reputation: 69

Accesing the information of a NSArray inside another NSArray

I am trying to pass data from a collection view controller to a table view controller. What i want is that when a user choose an item of the collection view then it pass the data of the item to a table view controller, and the table view controller presents the information of the item depending of the chosen item. But I don't know how to access the data of the NSArray that is inside of another NSArray.

This are all the member variables i declared inside the implementation file.

_arrayOfChaufa = @[@"qUESIto", @"Jodido", @"Ala", @"Que pajita", @"Wuauau", @"Tengo hambrunita", @"jojolete", @"Sequito duro", @"Latititititito", @"Manusico"];

_arrayOfLomo = @[@"Que novedada", @"jajajaja que buena", @"Lukita", @"losisisisi", @"maniserio", @"joder", @"joselet", @"lskadlkdl", @"bah"];

_arrayOfPapita = @[@"que buena!", @"csm!!", @"que genio!", @"novedades", @"que rico!!", @"coger delicisioso", @"Mffffff"];

_arrayOfParihuela = @[@"Un culaso", @"Chambon", @"Noveades", @"que hacer", @"asu macho", @"Espero que este bien", @"Así es la vida la chamba", @"Debo aprender mas!!"];

_arrayOfTacacho = @[@"Tacachin", @"Lalilinnn", @"Masinisn", @"Joder", @"Ojojoojojo", @"Lista hermosa!"];

_arrayOfAnticucho = @[@"Me encanta Objective-c", @"Hermosisimo", @"Me encanta xcode!", @"Que hermoso es esto", @"Debe ser un chambon total", @"jajajaja novedades", @"Lol supremo"];

_arrayOfCuy = @[@"Te me querías escapar ahhhhh jajajaj", @"Noveades de la vida", @"Jojojojojojo", @"Apple eres el MEJOR!!!"];

_arrayOfPachamanca = @[@"eL Ultimo array de la lista", @"Lo lograre carajo!", @"Esto es facil", @"Si se puede carajo", @"Mi primera aplicación!", @"Sobreviviree guerreros!!"];


 ***THIS IS THE NSARRAY THAT CONTAINS ALL THE NSARRAYS***
_arrayOfIngredients = @[@"_arrayOfCeviche, _arrayOfPachamanca, _arrayOfLomo, _arrayOfCuy, _arrayOfChaufa, _arrayOfAnticucho, _arrayOfParihuela, _arrayOfTacacho, _arrayOfPapita"];

MY PROBLEM BEGINS HERE.....

- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
[self performSegueWithIdentifier:@"showDetail" sender:indexPath];
}

    // Method to pass data to another view
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

      if ([segue.identifier isEqualToString:@"showDetail"]) {

          NSIndexPath *indexPath = (NSIndexPath*)sender;

          DetailViewController *dvc = [segue destinationViewController];

           ***THIS PART IS MY PROBLEM PLEASE HELP ME***
          dvc.Titulos = [_arrayOfIngredients objectAtIndex:indexPath.row];
          }
     }

Upvotes: 0

Views: 59

Answers (1)

iCode
iCode

Reputation: 1466

Don't use an NSString here:

_arrayOfIngredients = @[_arrayOfCeviche, _arrayOfPachamanca, _arrayOfLomo, _arrayOfCuy, _arrayOfChaufa, _arrayOfAnticucho, _arrayOfParihuela, _arrayOfTacacho, _arrayOfPapita];

Upvotes: 4

Related Questions