Created
April 15, 2012 22:26
-
-
Save 0xced/2395119 to your computer and use it in GitHub Desktop.
Alternative iOS device unique identifier
This file contains 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
#import <UIKit/UIKit.h> | |
@interface UIDevice (HostUUID) | |
- (NSString *) xcd_uniqueIdentifier; | |
@end |
This file contains 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
#import "UIDevice+HostUUID.h" | |
@implementation UIDevice (HostUUID) | |
- (NSString *) xcd_uniqueIdentifier | |
{ | |
CFUUIDBytes uuidBytes; | |
gethostuuid((unsigned char *)&uuidBytes, &(const struct timespec){0, 0}); | |
CFUUIDRef uuid = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault, uuidBytes); | |
CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuid); | |
CFRelease(uuid); | |
return [CFBridgingRelease(uuidString) lowercaseString]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment