//
// DidRunBeforeAppDelegate.m
// DidRunBefore
//
// Created by kaydell on 5/2/10.
//
#import "DidRunBeforeAppDelegate.h"
@implementation DidRunBeforeAppDelegate
@synthesize window;
// the function alert() displays an alert to the user
void alert(NSString *title, NSString *message) {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: title
message: message
delegate: nil
cancelButtonTitle: @"OK"
otherButtonTitles: nil
];
[alert autorelease];
[alert show];
}
// Override point for customization after application launch
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// get the standard user default object
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// read the flag to see if the application was ran before
BOOL ranBefore = [defaults doubleForKey: @"ranBefore"];
// set a flag that this application has been run before
[defaults setBool:YES forKey:@"ranBefore"]; // set a flag in secondary storage
[defaults synchronize]; // save to disk
// do processing depending upon whether the app has be run before or not
if (ranBefore)
alert(@"Welcome Back", @"This app has been run before");
else
alert(@"Welcome", @"This app is being run for the first time.");
[window makeKeyAndVisible];
return YES;
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end