Global Variables In iOS?

Joined
Oct 11, 2011
Messages
46
Reaction score
0
Points
6
Your Mac's Specs
13" MacBook Pro 2.4 GHz 8 GB Ram 250 GB HD, iPhone 4/S 64 GB, iPhone 3GS 16 GB, iPad 16 GB Wi-Fi
are there global variables in iOS? if so how can i make a variable global?


if not, whats the best way to make a variable sharable between view controllers?
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
See this Wikipedia entry about global variables and read the section on C & C++. It should apply to Objective-C as well, since Objective-C is a superset of C.

If your global variable is going to be an object, then look into the singleton.

Lastly, if one view controller is calling the other one, just pass a reference to the firsts local variable.
 
OP
L
Joined
Oct 11, 2011
Messages
46
Reaction score
0
Points
6
Your Mac's Specs
13" MacBook Pro 2.4 GHz 8 GB Ram 250 GB HD, iPhone 4/S 64 GB, iPhone 3GS 16 GB, iPad 16 GB Wi-Fi
thanks for the advice
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top