THE_DOM's answer is good, but I somehow fixed my problem.
To find out if we need to change modally, we check to see if there are any elements in our delegate method in our wish list. If not, we will say that to happen. If it has elements, then push segue will be automatically called instead of it (configured in IB).
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { Wishlist *wishlist = [self.fetchedResultsController objectAtIndexPath:indexPath]; if([wishlist.items count] == 0) {
In our prepareForSegue we set BOOL to indicate to the user who clicked on the empty wish list (this is at our VC destination).
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; ...
And then when we relax, we check to see if there is BOOL YES or NO .
- (IBAction)saveWishlistItem:(UIStoryboardSegue *)segue { ManageWishlistItemCDTVC *manageWishlistItemVC = (ManageWishlistItemCDTVC *)segue.sourceViewController; // check to see if we came from edit segue or add segue if(manageWishlistItemVC.tappedOnEmptyWishlist) { // edit segue // saved edited wishlist } else { // add segue if([manageWishlistItemVC.selectedItems count] > 0) { // save new wishlist } }
source share