I want to call a web-service to get the users information, and after I want to be able to access this information from anywhere in our application using like this:
MyDelegate *delegate = [[UIApplication sharedApplication] delegate];
user = delegate.u;
Is setting an instance variable as a User object in the app delegate and referencing it from there when needed a poor way of going about it? I typically set it there upon the user's login.
Tarun Kumar
14-Dec-2015Normally, you should only connect things to the app delegate if they:
Were created from the same NIB file as the app delegate (static UI elements in single window interfaces)
Are associated with application-level event handling that passes through the app delegate (like the menu item for the Preferences Window)
For everything else, you should create a singleton which manages access to them.
In my programs I normally avoid this, as I think it puts too much responsibility at the top level - I think things should self-manage where possible and that higher level management should only be used when there is a requirement for coordination between peer-level modules.