Segue Data Transfer Best Practice

DannyBres

macrumors 65816
Original poster
Oct 30, 2007
1,413
6
UK
Today I have a VC (say called pickVC) that allows the user to pick from a list, i present it modally. I have implemented it like UIImagePickerController, it has a delegate protocol that has didPickItem... didCancelSelection... etc. This works well today.

I create an instance of pickVC, set delegate as the presentingVC, present it, on didSelectRowAt... I fire the delegate method and dismiss it.

I think this is a good way to do it.

I know what to change the architecture to be a UISplitViewController, from reading around, I should use a segue from my MasterVC to my DetailVC. Using a show detail segue, a brand new instance of the detailVC is created with each segue. In prepareForSegue, what is the best way to transfer the data? have a public method on the detailVC and call it from the masterVC to set it up? Use my delegate protocol still?

Thanks,

Daniel Breslan
 

1458279

Suspended
May 1, 2010
1,601
1,514
California
I'm going through the Code Coalition videos right now and just happen to be going through that subject right now. I'm not an expert on the process, he's using arrays and a dictionary for data storage and TBH, it's a bit of a convoluted process that I haven't become an expert on yet.

I'm wondering if storing in a traditional database system like SQLite or CoreData would be more straight forward.

One problem I noticed with the solution from Code Coalition was that if the data structure changes, you have to change the code.

I was thinking that a different object to store the data should be available to store the data in all objects.

Another option would be a singleton type approach for the data.

What method are you using now?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Yes, have a public method on the detailVC and set a data model object that lets the detailVC know what to display. The delegate protocol is probably not relevant.