objective c - How to access properties on AppDelegate from classes owned by it? -


i'm writing simple os x app far structured so:

  • the main business logic in appdelegate.m
  • there 2 viewcontrollers xibs appdelegate owns , presents in window

i need access properties on appdelegate viewcontrollers, i'm doing this:

appdelegate *delegate = (appdelegate *)[[nsapplication sharedapplication] delegate]; delegate.someproperty = somevalue; 

this "feels" hacky. proper pattern or dumb?

two alternative architectures came were:

  1. to use delegation , define kind of "ui delegate" protocol in vcs , make appdelegate conform it
  2. to have vcs post notifications appdelegate listens to

the first feels tangled , dirty, second feels unreliable.

what proper pattern here? how should vcs owned appdelegate access properties?

try this

appdelegate *app = [nsapp delegate]; 

instead of this

appdelegate *delegate = (appdelegate *)[[nsapplication sharedapplication] delegate]; 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -