Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone,

Is there anyone who could tell me how i could define global variables which I could start using in my entire application?

currently I've tried, However, it is throwing me errors obviously..:

http://plaatscode.be/141545/
http://plaatscode.be/141543/

errors on lines 7,8,9 of the second url:
- Assigning to 'NSString' from incompatible type 'id'
- Assigning to 'NSString' from incompatible type 'id'
- Assigning to 'Database' from incompatible type 'Database *__strong'

An alternative would be to pass these values directly to the statemachine.


C++
LoginStateMachine *machine = [[LoginStateMachine alloc] init];
[machine Login];




Anyone who could help me with defining global variables?

Kind Regards,
Lars
Posted
Updated 6-Jan-12 3:24am
v3
Comments
Richard MacCutchan 6-Jan-12 5:46am    
Well unless you show the code AND the error messages it's not likely we can guess what the problem is. And please post all the information in the updated question rather than a couple of unclickable URLs.
Richard MacCutchan 6-Jan-12 6:13am    
You still have not shown the code and indicated which lines the errors apply to. Please try and help us to understand the problem.

1 solution

The first idea that came into mind was a singleton, and surprisingly it is also the preferred method. Check out this link for more info:
http://derekneely.com/2009/11/iphone-development-global-variables/[^]

Good luck!
 
Share this answer
 
Comments
larssy1 11-Jan-12 4:53am    
I've ended up using something similar to Singleton, thanks for your advice.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900