Note that there are some explanatory texts on larger screens.

plurals
  1. POContainer Views & Passing Data
    primarykey
    data
    text
    <p>I am having difficulty passing data to a tableViewController that is housed within a container view as can be seen here:<br> <img src="https://i.stack.imgur.com/tGMea.png" alt="enter image description here"> <br>For context, the View controller which contains the two container views is itself the first tab of a tabViewController that act as the Master View for the Detail View of a splitViewController.</p> <p>First of all - am I using the container views appropriately? The purpose of this first tab is to display some filter 'settings' at the top which are editable via a push segue (hence its being a navigation controller), and at the bottom, the tableView's data will update based on the filter criteria. It seemed intuitive to use two container views to accomplish this functionality, but I have very little experience and don't know if there is a better way or if container view's utility is more niche-y than it would seem.</p> <p>To the original question - presuming this hierarchy makes sense, I am having difficulty passing data to this particular tableViewController. There are two other tabs in the tabViewController, neither of which utilize a container view and so I have been able to successfully traverse the hierarchy to display data in these tabs using the appDelegate as follows:</p> <pre><code>// Initial Setup UISplitViewController *splitViewController = (UISplitViewController *) self.window.rootViewController; UITabBarController *masterTabBarController = [[splitViewController viewControllers] objectAtIndex:0]; // Tab 1: Filter by Location: // &gt;&gt;&gt; **PROBLEM CODE SEGMENT** &lt;&lt;&lt; UIViewController *containerViewController = [[masterTabBarController viewControllers] objectAtIndex:0]; MasterViewController *masterViewController0 = [[containerViewController childViewControllers] objectAtIndex:1]; masterViewController0.slotMachines = machines; // Tab 2: Filter by ID#: MasterViewController *masterViewController1 = [[masterTabBarController viewControllers] objectAtIndex:1]; masterViewController1.slotMachines = machines; // Tab 3: Audited MasterViewController *masterViewController2 = [[masterTabBarController viewControllers] objectAtIndex:2]; masterViewController2.slotMachines = machines; </code></pre> <p>I have skipped the snippet of code that assigns data via delegate to each of masterViewController0/1/2. As mentioned, Tabs 2 and 3 work. Tab 1 breaks the program at runtime, terminating due to '[containerViewController childViewControllers]' returning an empty array, and so the call for objectAtIndex:1 (which I had hoped would refer to the tableView) is out of bounds. I wonder if the containerview is not initialized at this point in program execution? But I honestly have no idea.</p> <p>I think my query has less to do with container views specifically and more to do with hierarchy traversal, and so despite looking into solutions in documentation on container views, I really have not found much help.</p> <p>Thanks you in advance for any tips!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload