Revision: 46840
                            
                                                            
                                    
                                        
Initial Code
                                    
                                    
                                                            
                                    
                                        
Initial URL
                                    
                                    
                                                            
                                    
                                        
Initial Description
                                    
                                    
                                                            
                                    
                                        
Initial Title
                                    
                                    
                                                            
                                    
                                        
Initial Tags
                                    
                                    
                                                            
                                    
                                        
Initial Language
                                    
                                    
                                                    
                        at May 26, 2011 14:19 by zingo
                            
                            Initial Code
-(void)awakeFromNib{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
BOOL hasRanBefore = [defaults boolForKey:@"hasRanBefore"];
[defaults setBool:YES forKey:@"hasRanBefore"];
[defaults synchronize];
if (hasRanBefore) {
NSAlert *iRanBefore = [NSAlert alertWithMessageText:@"I Ran Before" defaultButton:@"OK" alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"This application has run before."];
[iRanBefore runModal];
} else {
NSAlert *iDidNotRunBefore = [NSAlert alertWithMessageText:@"I Didn't Run Before" defaultButton:@"OK" alternateButton:@"Cancel" otherButton:nil informativeTextWithFormat:@"This application has not been run before."];
[iDidNotRunBefore runModal];
}
                                Initial URL
http://programmersweb.blogspot.com/2011/05/checking-if-you-app-has-been-run-before.html
Initial Description
Do you need you app to do something when it is first run on a certain computer? Do you need to know if it has been run before? Enter the following code into your Application Delegate. This code creates a BOOL that is created when the app is run. The if-else statement reads the value of the BOOL -- Yes or No. NOTE: You'll notice that if you run the app from xcode with the run button it says "Not run before". When you run it again it still says that. In order to truly test locate you apps Debug .app application then run that. Xcode clears out the data when you run it again. IT DOES WORK though, so don't worry if running you app in Xcode still gives you the Not Run Before result.
Initial Title
Checking If You App Has Been Run Before
Initial Tags
osx
Initial Language
Objective C