Tag Archives: Singleton

Global Variable in Objective C

Using Global Variable in Objective C, allow you to store static information or values similar to Microsoft.NET C#.

In this post, we are going to using the Singleton design pattern.

Step 1: Create the class in Xcode, add both the header and method file (.h / .m), call it GlobalVariables.

Step 2: Add the following content into your header file.

Step 3: Add the following content into your method file.


At this stage, you will be wondering what does all these do. You will be adding @property for those value that you want to be able to access globally in the header file and synthesize them in the method file.

How do we use them?

To access the singleton, you need to import the header file.

First, saving data to the singleton.

Getting Data from the Singleton