iphone - Global variables and objects in Objective C. What is the best way? -
After
I want to use global variables and objects for iphone project.
I have created NSObject class and defined as below:
.h file: Meter file: What is the best way or should I use the singleton pattern like the link answer below: Share the idea Text after " The way in which to use the global variable in the application is: You Application representative class can only be used> .h file: .m file: You can now use strUserID as a global variable in your UIViewController: You can set the price: Get the value: :)
#import & lt ; Foundation / Foundation. H & gt; @ Interface Global Class: NSOBX Extension NSSSing * IISST; External NSMUttAbra * Armarta; @end
#import "GlobelClass.h" @implementation GlobelClass NSString * mystr; NSMutableArray * Arrdata; @end
app delegate: uirponder & lt; UIApplicationDelegate & gt; {} @property (non-rigorous, strong) NSString * strUserID;
@ synthesis strUserID;
ABCProjectAppDelegate * AppDelegate = (ABCProjectAppDelegate *) [ UIApplication sharedApplication] representative];
appDelegate.strUserID = @ "test";
NSString * strId = appDelegate.strUserID;
Comments
Post a Comment