For learning iOS programming I’m developing an iPhone application for sharing images. The application is the client for a website.
In the method didFinishLaunchingWithOptions I check if the user is already logged in.
If the user isn’t logged in he can still see all parts of the applications but for example he wouldn’t see option button for editing profile, comment on images, etc.
How can I share the logged/or not status throughout all view controllers?
Update: If giving this advice today, I would say use a shared instance:
Then it is auto-instantiated for you on first use, and available throughout your app:
You can use a singleton – a global, shared instance of an object.
Then, when you need to access your object in another source file, you import the header file for your singleton in the other header, like you would for any other reference.
Create a singleton:
Use/read a singleton:
Or, you can create a singleton implementation that auto-inits the first time you access it: