Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

gwelmarten

macrumors 6502
Original poster
Hi
I'm detecting the number of times my Mac application has being opened using the following code:
Code:
 NSString *currentVersion = (NSString*)[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
    NSArray *prevStartupVersions = [[NSUserDefaults standardUserDefaults] arrayForKey:@"prevStartupVersions"];
    if (prevStartupVersions == nil) 
          {
          }
     else {
          }
 [[NSUserDefaults standardUserDefaults] synchronize];
However, this only works for detecting the first launch. How would I detect a second and third launch? I did try:
Code:
if (prevStartupVersions == 1)
However, I am comparing an NSArray with an Interger there. How should adapt this to detect a second launch?

Thanks in advance for any help,

Sam
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.