Skip to content

Instantly share code, notes, and snippets.

@0xced
Created April 15, 2012 22:26
Show Gist options
  • Save 0xced/2395119 to your computer and use it in GitHub Desktop.
Save 0xced/2395119 to your computer and use it in GitHub Desktop.
Alternative iOS device unique identifier
#import <UIKit/UIKit.h>
@interface UIDevice (HostUUID)
- (NSString *) xcd_uniqueIdentifier;
@end
#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