Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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.
 

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

 
Anyone who could help me with defining global variables?
 
Kind Regards,
Lars
Posted 6-Jan-12 0:43am
larssy1367
Edited 6-Jan-12 4:24am
v3
Comments
Richard MacCutchan at 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 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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!
  Permalink  
Comments
larssy1 at 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)



Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 6 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100