I would like to add some constant keys for my application, these constants can be obtained anywhere in the program. Therefore, I declare constants in the interface file:
#import <UIKit/UIKit.h> NSString * MIN_INTERVAL_KEY = @"MIN_INTERVAL_KEY"; NSString * MAX_TOBACCO_KEY = @"MAX_TOBACCO_KEY"; NSString * ICON_BADGE = @"ICON_BADGE"; @interface SmokingViewController : UIViewController { }
And I would like to access them from the MinIntervalViewController class:
- (void)viewDidAppear:(BOOL)animated { NSUserDefaults *user = [NSUserDefaults standardUserDefaults]; if (user) { self.selectedValue = [user objectForKey:MIN_INTERVAL_KEY]; } [super viewDidAppear:animated]; }
But the application shows an error in the MinIntervalViewController class:
error: "MIN_INTERVAL_KEY" is undeclared (first used in this function)
Did I miss something? Any help would be appreciated.
thanks
objective-c iphone cocoa-touch constants
haisergeant
source share