Global variables have always been a good thing and can bring a lot of convenience in development. The following describes how to use global variables during software development in iPhone: 1. Create constants. h file (the file name can be retrieved as needed), used to store global variables; 2. In constants. write the required global variable name in H, for example: Object-CCodeNsstring * master_url; // pointer type int count; // non-pointer type Note: initialization cannot be performed when defining global variables; otherwise, an error is returned! 3. Introduce this file in the file that requires the use of global variables: Object-C code # import "constants. H "4. initialize or assign a value to a global variable: Object-C code extern nsstring * master_url; master_url = [[nsstring alloc] initwithformat: @" http://www.wuleilei.com "]; // pointer type; allocextern int count; Count = 0; // non-pointer type 5. Use global variables: use [uiappcation sharedapplication] Like normal variables. delegate. name = @ ""; * appdelegate = (* appdelegate *) [[uiapplication sharedapplication] Delegate]; appdelegat E. Name = @ "Wang Cheng ";