Pages

Saturday 9 February 2013

How to have a global variable in iOS


1) put below code to your appdelegate .h file

@property (nonatomic, retain) NSMutableDictionary *lineDict;

2) use below code to access the global lineDict variable

SGBusesAppDelegate* delegate = (SGBusesAppDelegate*)[[UIApplication sharedApplication] delegate];
if (![[delegate lineDict] count])
      ...

Note: I manage to get the above by working on my rejected by iTune app ~ Bus and MRT. It always crash when apple test it but not with me. It is the biggest project that I have done. It takes me 2 months to complete. Luckily all is not wasted, the experience and knowledge is use in many other apps.

No comments:

Post a Comment