Parameters for a Container View

1

The scenario is as follows:

  

I own a UIViewController and within this controller I own   a UITableViewController added as a ContainerView .

How do I pass parameters between my UIViewController and my ContainerView ?

For example, I want to pass from my UIViewController a list of items to be displayed in my ContainerView ( UITableViewController ).

    
asked by anonymous 05.12.2014 / 13:31

1 answer

2

You simply have a public method in your UITableViewController and run it by UIViewController . Let's assume your UITableViewController has the following method in your header:

- (void)preencheTabela:(NSArray *)lista;

And the implementation:

- (void)preencheTabela:(NSArray *)lista {
    // TODO preencher sua lista atual com a recuperada
    [self.tableView reloadData];
}

And in your UIViewController , once you have the reference of Controller with the table that was inserted in container , just run your method:

[self.referanciaTabela preencheTabela:listaEnviada];

Clarifying that it is not for the container that you will pass, but for the Controller that is inside the container . Is it clear?

Your reference, already with the container added from the storyboard , looks more or less like this in viewDidLoad: eg:

self.referanciaTabela = [self.childViewControllers firstObject];
    
05.12.2014 / 14:29