2011-04-15 50 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; 
} 
相關問題