Skip to content

Instantly share code, notes, and snippets.

@stephenkeep
Created September 19, 2013 08:46
Show Gist options
  • Save stephenkeep/6620731 to your computer and use it in GitHub Desktop.
Save stephenkeep/6620731 to your computer and use it in GitHub Desktop.
//ios6
SString *UUID = [[NSUUID UUID] UUIDString];
//ios5
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSString *UUID = [[NSUserDefaults standardUserDefaults] objectForKey:kApplicationUUIDKey];
if (!UUID) {
CFUUIDRef uuid = CFUUIDCreate(NULL);
UUID = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
[[NSUserDefaults standardUserDefaults] setObject:UUID forKey:kApplicationUUIDKey];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment