Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I figured it out. Hope I help someone. I'll explain the code first then post it below. Basically, I set the data source of the root table view, "ObjectSelect", as a <code>NSMutableArray</code> called "currentObjectArray". ObjectSelect is also the ObjectSelectPopoverDelegate. Basically, when a cell in the popover is tapped, it adds the object tapped to the "currentObjectArray" and reloads the tableview. </p> <p>ObjectSelect.h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "ObjectSelectPopover.h" @interface ObjectSelect : UITableViewController&lt;ObjectSelectPopoverDelegate&gt; @property (nonatomic, strong) ObjectSelectPopover *objectPicker; @property (nonatomic, strong) UIPopoverController *objectPickerPopover; @property (readwrite, nonatomic) Object *currentObject; @property (nonatomic, strong) NSMutableArray *selectedObjectArray; @end </code></pre> <p>ObjectSelect.m</p> <pre><code>-(void)selectedObject:(Object *)newObject { _currentObject = newObject; if(!_selectedObjectArray){ _selectedObjectArray = [[NSMutableArray alloc] init]; } if([_selectedObjectArray containsObject:_currentAthlete]){ //lol you don't get added, bub } else{ [_selectedObjectArray addObject:_currentObject]; } [self.tableView reloadData]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; Object *objectTapped = (Object *)[_objectAthleteArray objectAtIndex:indexPath.row]; return cell; } </code></pre> <p>ObjectSelectPopover.h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "Object.h" @protocol ObjectSelectPopoverDelegate &lt;NSObject&gt; @required -(void)selectedObject:(Object *)newObject; @end @interface ObjectSelectPopover : UITableViewController @property (nonatomic, weak) id&lt;ObjectSelectPopoverDelegate&gt; delegate; @property (nonatomic, strong) NSMutableArray *objectArray; @property (readwrite, nonatomic) Object *currentObject; @end </code></pre> <p>ObjectSelectPopover.m</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { _currentObject = [_objectArray objectAtIndex:indexPath.row]; //Notify the delegate if it exists. if (_delegate != nil) { [_delegate selectedObject:_currentObject]; } [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; } </code></pre>
 

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