Wednesday, May 16, 2012

Delegation to SecondViewController inside a NavigationController presented Modally

I'm really not sure how to express this question in the fewest and clearest words possible. But I'll try my best.



I have a class ShoppingCartVC and I want to add products to it. So I modally present a CategoriesVC modally. When I select a category in the tableView row, it segues to a ProductsVC containing all the products in that category. So now I can select a product. But how do I send that selected object back to ShoppingCartVC? I was able to successfully implement this before using delegation but that was when I didn't have the CategoriesVC. I just segue directly to the ProductsVC so before I segue, I can set ShoppingCartVC(the presenting VC) as the delegate of ProductsVC and dismiss it whenever a product is selected.



But now since ProductsVC is 1VC further down the VC hierarchy in my navigationController, I cannot do that.



I tried searching about NSNotification but that doesn't seem to be the right solution.



How do I solve this? Hopefully you can give me some sample codes.





No comments:

Post a Comment