From the view A I open the View B which contains categories in a uitableview, when I select a category I open the view C which contains subcategories for the category (using the CoreData persistence ) in a uitableview, when I select a subcategory I open the view D which contains all my product (using the CoreData persistence ), when I select the the product, how can I set the value into the view A? Avoiding leaks of course…
A(MainWindow)->B(UITableView with category)->C(UITableView with subcategory)->D(UITableView with products)
D->C(with the selected product)->B(with the selected product)->A(with the selected product)
I hope I’m enough understable 😀
Thank you
This approach assumes you are using an
UINavigationControllerwith a stack ofUIViewControllerinstances, each of which having a managed object context instance as a part of a Core Data application.Set up an
ivarand a@propertyin your application delegate header that holds a value for the selected product (anNSManagedObjectID*, for example):Synthesize this
ivarin the implementation, and release it in-dealloc:Set up the following macro wherever you keep your constants, or in each view controller header:
From any view controller, thereafter, you will be able to set and access your
selectedProductvalue, e.g.:You don’t necessarily have to use an
NSManagedObjectID*here. You can use any class you like.