performWithSegue not working

Discussion in 'iOS Programming' started by grandM, Jan 16, 2016.

  1. grandM, Jan 16, 2016
    Last edited: Jan 16, 2016

    grandM macrumors 6502a

    grandM

    Joined:
    Oct 14, 2013
    #1
    So I have this splitview. On the left hand side you have the tableView. It has this plus sign. When I tap it I create a new managedObject Woman. I set a stored variable property on detailVC called woman. Then I segue from detailVC to editVC changing data. When I hit the plus sign everything works as it should.

    When however I first select another woman in my tableView (showing her data on the detailVC) and then hit the plus I'm not seguing. Anyone know why?

    Code:
    self.detailViewController!.woman = woman
    self.detailViewController?.managedObjectContext = self.managedObjectContext
    self.detailViewController?.performSegueWithIdentifier("editWomanSegue", sender: self.detailViewController!
    )
    
    I looked in the prepareForSegue of the detailVC. In prepareForSegue of detailVC I'm doing:
    Code:
    let editVC = segue.destinationViewController as! EditWomanViewController
    
                editVC.managedObjectContext = self.managedObjectContext
    
                editVC.woman = self.woman
    
    I put a print on the setting of the woman stored variable property in editWomanVC and yes it is set. Only problem is the View is not shown or loaded (viewDidLoad isn't called for) :s
     
  2. grandM thread starter macrumors 6502a

    grandM

    Joined:
    Oct 14, 2013
    #2
    I might have found the solution. I have it running now. I solved it by first performing a segue from the masterVC to the detailVC. In the detailVC I'm performing again a segue to the editWomanVC when an attribute of woman is empty in the detailVC. This works. I still wonder why I could not perform a segue on the detailVC with
    Code:
           self.detailViewController?.performSegueWithIdentifier("editWomanSegue", sender:self.detailViewController!)
    
    though. I hope this answer will save somebody else a lot of cursing though.
     
  3. grandM thread starter macrumors 6502a

    grandM

    Joined:
    Oct 14, 2013
    #3
    I think I know where the problem resolved of. It seems if you have a split view and segue from the detailVC to editWomanSegue the mainVC does not appear in editWomanSegue's navigation stack...
     

Share This Page