Here two points recorded knowledge iOS developers often used, is a unique identifier, it is a global variable.
(1) unique identification
Uniquely identify a device (such as iPhone, iPad, etc.) demand on a basic implementation of business because of this unique identification in many scenarios need to use, such as for statistics (Nikkatsu, the total number of users), another example as the default account, and so on.
udid, once the only choice for identification, such as this made:
NSString *UDID = [[UIDevice currentDevice] uniqueIdentifier];
However, udid has been Apple refused to use, so this is not a small way choice. Similarly, mac address, and it was banned from Apple.
Other methods, such as IDFA, IDFV, UUID, have limitations, but that does not mean you can not use - can be combined and used in conjunction with keychain, thereby circumventing defects as possible.
Such a scheme has already been achieved, such as this project:
https://github.com/herody/UQIDDemo
The above referenced project UQID directory file, you can get a unique identification devices, such use:
(2) global variables
In order to facilitate information and synchronize projects often require the use of global variables.
Design global variables, there are two general ways.
A way, defined in AppDelegate.h global variables, that is, an increase in class AppDelegate global variables, such as:
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, assign)BOOL firstrun;
Then, anywhere, you can access AppDelegate, such as:
AppDelegate *myDelegate = [[UIApplication sharedApplication] delegate];
myDelegate.firstrun = YES;
The second method is to use a new file, define a single embodiment of the class, such as the so defined globalvar.h:
In globalvar.m in this definition:
Thereafter, it can be used anywhere in the global variable - to be used by a single embodiment function, like this: