// // SetPrefsAppDelegate.h // #import @interface SetPrefsAppDelegate : NSObject { BOOL saveUsername; NSInteger preferredIndexInTabbar; UIWindow *window; } @property (nonatomic, retain) IBOutlet UIWindow *window; @end // SetPrefsAppDelegate.m // #import "SetPrefsAppDelegate.h" #import "Preferences.h" //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // App Delegate implementation //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @implementation SetPrefsAppDelegate @synthesize window; /*------------------------------------------------------ * Read preferences from system *-----------------------------------------------------*/ -(void) loadPreferences { saveUsername = [Preferences shouldSaveUsername]; preferredIndexInTabbar = [Preferences startupTab]; } /*------------------------------------------------------ * Application startup code *-----------------------------------------------------*/ - (void)applicationDidFinishLaunching:(UIApplication *)application { // Load user preferences (notice the default values the first time through) [self loadPreferences]; // Show the current values of the preferences NSLog(@"Save user preferences: %s", saveUsername == YES ? "Yes" : "No"); NSLog(@"Preferred startup tab: %d", preferredIndexInTabbar); // This is a little contrived, but you get the point... BOOL saveUname = YES; NSInteger index = 3; // Write new values to the sytem [Preferences setPreferences:saveUname startupTab:index]; // NSLog(@"Home: %s", NSHomeDirectory()); // NSLog(@"Home: %@", NSHomeDirectory()); // Override point for customization after application launch [window makeKeyAndVisible]; } - (void)dealloc { [window release]; [super dealloc]; } @end //objectc/4009