Reputation: 5801
This should be simple but I am scratching my head on this. I have declared a static variable on the app delegate header file. Something similar to,
static NSString *baseURL = @"http://www.google.com/";
I change the value of the static variable during the method,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
When I observe the variable using the breakpoint in AppDelegate file , I can see that the value is changed. However when I access the static variable from a different file aka a ViewController I get the old value . Why is this ?
Is there any way I can get the new value ?
Upvotes: 0
Views: 131
Reputation: 2918
I would suggest you to
NSString
property in your AppDelegate.h
fileAppDelegate.m
didFinishLaunchingWithOptions:
set your variables valueAppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
appDelegate.baseURL = @"google.com";
Upvotes: 2
Reputation: 10096
Yo should not use static if you are going to change values.
To get access to "global" strings you need to use extern:
appDelegate.h
extern NSString *externString;
appDelegate.m
NSString *externString = @"some value";
Also you can change the value anywhere.
Upvotes: 4