title: ipad uisplitview: passing data from masterviewcontroller to a uiviewcontroller (redirected via segue)
body: <p>I'm new to iOS programming so I want to make this thing from scratch to be able understand how the whole thing works. So instead of using the master detail template I did this from the ground up.</p>
  
  <p>I'm having a huge roadblock in terms of passing data between the master view and the detail view. At the moment, whenever I tap on the item of the master view it would look for the first view on the detail view controller, let's call it <code>mainswitchviewcontroller</code>. It's the first <code>ViewController</code> connected via segue to the <code>UINavigationController</code> for the detail controller part (Please refer to image below). </p>
  
  <p>This happens after login where it shows that <code>viewcontroller</code>, I want the user to pick an option before accessing the whole app. which will lead them to the last <code>ViewController</code> of the flow (refer to the image below - red circle). </p>
  
  <p><img src="https://i.stack.imgur.com/9AA7i.png" alt="Flow diagram"></p>
  
  <p>Now what I'm trying to do is this:</p>
  
  <pre><code>@interface MasterListViewController : UITableViewController{
  }
  
  @property (nonatomic) int matNum;
  @property (strong, nonatomic) DetailStaffMainContentViewController *detailViewController;
  @end
  
  :
  :
  
  @implementation MasterListViewController
  @synthesize matNum;
  :
  :
  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
  
      for(UIViewController *vc in self.splitViewController.viewControllers){
          NSLog(@"%@)", vc.title);
      }
  
      self.detailViewController.teststring = @"gronk";
  }
  </code></pre>
  
  <p>This is my detailViewController (the one I want to access)</p>
  
  <pre><code>@implementation DetailStaffMainContentViewController
  @synthesize tableView;
  @synthesize teststring;
  @synthesize lblOutput;
  </code></pre>
  
  <p>Now on select of the row, I assign the <code>teststring</code> which I want to use to populate that label on the controller. That's what I did. </p>
  
  <p>My questions are:</p>
  
  <ol>
  <li><p>I'm getting an error. Wondering what I was doing wrong?</p>
  
  <pre><code>[MainSwitchBoardViewController setTeststring:]: unrecognized selector
  sent to instance 0x7572190
  </code></pre></li>
  <li><p>Is this a recommended way of passing data? Or should I just stick with notificationcenters?</p></li>
  </ol>
  
  <p>Thoughts?</p>
  
  <p><strong>EDIT</strong>
  Just to give you on the flow of the app:</p>
  
  <ol>
  <li><p>User logs in (if username does not exist, the floating viewcontroller will pop up and force the user to log in.</p></li>
  <li><p>Once the user logs in, the pop up goes away and then asks the user what type of role is to be used in the current session (eg. staff or fighter).</p></li>
  <li><p>If the user picks fighter, it pushes the user to the top VC    If the user picks staff, it pushes the user to the bottom VC (collections controller) </p></li>
  <li><p>FOR Staff: At the moment I'm pushing to the last VC with this  [self perfermSegueWithIdentifier:sender:self] </p>
  
  <p>Once the user gets shown the last VC (DetailsStaffView), I want this to be the main Details View where the user does it's transaction. A few more pop ups? (Or maybe another push to another VC for specific transaction needs to be added). But ultimately I <strong>don't want</strong> the user to access the <strong>first Viewcontroller (MasterSwitchBoard)</strong></p></li>
  </ol>
  
  <p><strong>EDIT 2</strong>
  This is the main switch board class that controls the first VC after login.</p>
  
  <pre><code>@interface MainSwitchBoardViewController : UIViewController{
  
  }
  
  @property (strong, nonatomic) IBOutlet UILabel *txtLabel;
  - (IBAction)btnStaff:(id)sender;
  - (IBAction)btnAdmin:(id)sender;
  
  @end
  </code></pre>
  
  <p>This is the collections VC which atm automatcially pushes to the last VC. In the beginning I was using a notification on this but it seems like it's not necessary so I took it out.</p>
  
  <pre><code>@interface MatListCollectionViewController ()
  
  @end
  
  @implementation MatListCollectionViewController
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view.
  
      [self performSegueWithIdentifier:@"SeguePushToStaffDetailFromMats" sender:self];
  }
  </code></pre>
  
  <p>And then the details staff</p>
  
  <pre><code>@interface DetailStaffMainContentViewController : UIViewController{
  
  }
  
  @property (strong, nonatomic) IBOutlet UITableView *tableView;
  @property (nonatomic, retain) IBOutlet UILabel *lblOutput;
  @property (nonatomic, retain) NSString *teststring;
  
  @end
  
  
      @implementation DetailStaffMainContentViewController
      @synthesize tableView;
      @synthesize teststring;
      @synthesize lblOutput;
  </code></pre>