access an integer and string globally in iphone?


access an integer and string globally in iphone?



i want to access a integer and a string from a class to all the other classes? what is the best way to do it? i want to increase the values any where in the program and then want to update them in the class declared....

any idea how to achieve this???


inheritance in objective C

1:

Program to change the phone numbers a call is redirected to if a mobile phone cannot be reached?
Here's a question (and good answers) around singletons.. How to change UITabBar Selection color You could also use the app delegate, as frankodwyer suggested, and access it from anywhere using:. iPhone SDK: GameKit and large files + connection lost
id delegate = [[UIApplication sharedApplication] delegate]; 
For ease of use and type safety I use a category like this:. remove every type of subview from uiscrollview?
// put his in your delegate header file @interface UIApplication(MyAppAdditions) + (MyAppDelegate*)sharedDelegate; @end  // put his in your delegate implementation file @implementation UIApplication(MyAppAdditions) + (MyAppDelegate*)sharedDelegate {     return (MyAppDelegate*)[[self sharedApplication] delegate]; } @end 
Now you must access your app delegate from everywhere: [UIApplication sharedDelegate]. Read header files and do something before full photo upload happens
how to send objecs from an iPhone app to a server app using XML?What dpi resolution is used for an iPhone App?

2:

You could make the integer and string properties of your app delegate and pass references to the delegate around to your views. I did any thing like this myself, though to be honest it is a pain and also a little error prone to make the app delegate available to all the views.. Or (and this is probably better), you could declare a singleton class (google the singleton pattern) as one of your data classes, and have your integer/string be properties of that. Then you could access the receive ters/setters of your singleton from anywhere in your program. You will need to take extra care if you have multiple threads however,.


58 out of 100 based on 43 user ratings 318 reviews