Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Is this the the correct way for accessing these variables or should I be doing something differently?</p> </blockquote> <p>You'll find that different people have different opinions about this. The style that I prefer is to have the app delegate pass the necessary information to the first view controller, and have that view controller pass it on to whatever view controllers it creates, and so on. The main reason for this is that it prevents child view controllers from depending on things that they have no business knowing about.</p> <p>If you have some detail editor, for example, you want to be able to pass that editor exactly what it needs to do its work. If you give it that information, the editor is completely flexible -- it'll edit any information that you give it. If the editor knows that it should get its data from some external object, like the app delegate, then it loses some degree of flexibility -- it can <em>only</em> get data from the thing that it knows about.</p> <p>So, it's fine to set up your data model in the app delegate. But when it comes to providing access to the model, think: <strong>tell, don't ask</strong>. That is, have the app delegate <em>tell</em> the first view controller what model object to use, and have that controller <em>tell</em> the next one, and so on. If you have to <em>ask</em>, you have to know <em>who</em> to ask, and that's where the dependencies start heading in the wrong direction.</p> <blockquote> <p>every time I import AppDelegate into a .m file to access these variable's data I feel like I'm doing some wrong.</p> </blockquote> <p>Trust that instinct. Think about <em>why</em> it feels wrong.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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