iphone - What is the best way to refer to a model API from a view controller? -
i hate singletons , know if there better , cleaner way pass model reference view controller use it's api.
dont hate singletons, learn use them appropriate.
that said, if don't want use singleton can instantiate model controller in app delegate or 'root' view controller , pass reference of view controllers need (just pass other configuration data).
on singletons, appropriate when have content should exist once , needs exist lifetime of app. state shared between multiple areas of app. singletons aren't choice in object oriented language makes sense have instantiated object own , manage particular state , knowledge.
people abuse app delegate , give number of inappropriate responsibilities, using singleton provide better app structure.
Comments
Post a Comment