Note that there are some explanatory texts on larger screens.

plurals
  1. POways to bind model classes in Objective-C
    text
    copied!<p>(I hope someone will correct my terminology if I get it wrong -- I'm still sorting out terms)</p> <p>I have a series of classes in my model. I need to get some data from a url (SatDataGetter) and combine it with a location and date specific calculation (DayCalculater), do some further calculations (DataMixer), some interpretation to make it user-understandable (Advisor), and then present the results in a view. </p> <p>There are issues with setting up the dependencies and making sure that, for instance, the SatDataGetter has valid data <strong>before</strong> it gets called by DataMixer, <strong>before</strong> it gets called by.. you get the idea. Of course, if the location changes, I need to update the whole thing from the bottom up. At minimum I have to get a message to the ViewController and the Advisor to reload their data. </p> <p>The research I've done suggests that NSNotification is one way to go, but I could also try Key-Value Observing. I found some old posts (2009) on KVO, suggesting some possible problems and difficulties with debugging. <a href="http://www.mikeash.com/pyblog/key-value-observing-done-right.html" rel="nofollow">http://www.mikeash.com/pyblog/key-value-observing-done-right.html</a></p> <p>What's the preferred method? What are the issues I should be considering in deciding -- For instance: The SatDataGetter essentially returns a single number. KVO seems like a reasonable way for DataMixer to keep track of what that value is, but I don't think I want all the parent classes to be doing KVO on the dependent variables.</p> <p>When do you choose an NSNotification and when KVO?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload