2011-04-15 51 views

回答

3

注意[的UIDevice currentDevice] UNIQUEIDENTIFIER]在iOS的弃用,为OS X,你可以从gethostuuid()或注册表例如为:

+ (NSString*)getMachineUUID 
{ 
    NSString *ret = nil; 
    io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); 
    if (platformExpert) { 
     CFTypeRef cfstring = IORegistryEntryCreateCFProperty(platformExpert, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0); 
     if (cfstring) { 
      ret = [NSString stringWithFormat:@"%@",cfstring];   
      CFRelease(cfstring);      
     } 
     IOObjectRelease(platformExpert);   
    } 
    return ret; 
} 
相关问题