[quote=“slassen”]Hi Christian, I feel like you’re my personal tutor–you’ve been helping me out a lot! Thanks!
Your post makes sense. I was the OP of that thread, I had my question answered in it so I didn’t read what followed. If only I did, I wouldn’t have had to post a new topic.
I’ve been using protocols since I couldn’t get this to work. I have been jumping around re-reviewing chapters and I briefly remember a mention to the MVC-Store concept. Is this (Homepwner’s [BNRItemStore sharedStore]) what you would recommend as your default method of passing data between view controllers? Or would you typically use protocols?[/quote]
That’s why I hang around the forums! Glad to help. And that topic morphed after your question was answered, so understandable that you didn’t see it. I’m actually glad that you started this post, as it’s more descriptive of the problem and might be easier for people with a similar problem to find.
First, what specifically could you not get to work? That is an important first step.
To answer your question specifically, I’ll give you the terrible “it depends”. In this circumstance, the code we have works well because the BNRItem that we are modifying already exists. So it is easy enough to give it to the BNRDetailViewController and say “hey, this BNRItem already exists, so when the user changes the values, change them on this specific BNRItem.”
Let me give you a (modified for anonymity) example of where I am using delegation (protocols) in an app I am currently working on for a client. The user is on Screen A and needs to choose a company, so there is a button that says “Choose Company”. When the user taps this, they are brought to Screen B where there is a list of companies. Screen B “tells” Screen A which company is picked by having Screen A be the delegate of Screen B. The delegate method is something like - (void)chooseCompanyController:(BNRChooseCompanyController *)controller didPickCompany:(BNRCompany *)company;
This works well because there are multiple companies. Firstly, Screen A doesn’t even know what companies exist (Screen B does a web service to get a list of companies), and secondly since there are multiple companies, Screen A of course doesn’t know which one the user will pick.
Hope that helps a little. If you give me examples of where you’d like to pass data around in your own applications, I can help you decide what a good format would be for doing so.