Question

I've set up the Xcode storyboard of my drill down table to branch out to two detail views.

I want it to segue to either one based on the status of the Budget object that I tapped in the table view. If the budget object has not been initialized, I want to to segue to the initializing view. If it has been initialized, I want it to segue to the detail view.

So far, this is what I have...

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    /*
     When a row is selected, the segue creates the detail view controller as the destination.
     Set the detail view controller's detail item to the item associated with the selected row.
     */

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

        NSIndexPath *indexPath = [self.budgetsTable indexPathForSelectedRow];
        BudgetDetailsViewController *detailsViewController = [segue destinationViewController];
        detailsViewController.budget = [self.budgetPlan.budgets objectAtIndex:indexPath.row];
    }
}

Of course, this only makes it segue to the detail view. I want it to use the "initializeBudget" segue for when the case is budget.initialized = false How do I implement a performSegue:withIdentifier: method to do this?

Était-ce utile?

La solution

You need to fire off the method performSegueWithIdentifier depending on your condition.

Something like:

if ([self.budgetPlan.budgets count] > 0) {
    [self performSegueWithIdentifier@"showDetailsOfBudget"];
} else {
    [self performSegueWithIdentifier@"createBudget"];
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top