Created
February 27, 2013 18:20
-
-
Save wjlafrance/5050213 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AppUniqueIdentifier.h | |
// ReinstallationUdid | |
// | |
// Created by William LaFrance on 2/27/13. | |
// Copyright (c) 2013 William LaFrance. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface AppUniqueIdentifier : NSObject | |
+ (NSString *)uniqueIdentifier; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AppUniqueIdentifier.m | |
// ReinstallationUdid | |
// | |
// Created by William LaFrance on 2/27/13. | |
// Copyright (c) 2013 William LaFrance. All rights reserved. | |
// | |
#import "AppUniqueIdentifier.h" | |
@implementation AppUniqueIdentifier | |
+ (NSString *)uniqueIdentifier | |
{ | |
CFUUIDRef uuid; | |
NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults; | |
if (![defaults valueForKey:@"UUID"]) { | |
uuid = CFUUIDCreate(NULL); | |
NSString *uuidString = (__bridge NSString *)CFUUIDCreateString(NULL, uuid); | |
CFRelease(uuid); | |
[defaults setObject:uuidString forKey:@"UUID"]; | |
[defaults synchronize]; | |
return uuidString; | |
} else { | |
NSString *uuidString = [defaults objectForKey:@"UUID"]; | |
return uuidString; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment