2013-10-03 84 views

回答

19
NSUUID *vendorIdentifier = [[UIDevice currentDevice] identifierForVendor]; 
uuid_t uuid; 
[vendorIdentifier getUUIDBytes:uuid]; 

NSData *vendorData = [NSData dataWithBytes:uuid length:16]; 
7

夫特2版本:

var uuidBytes: [UInt8] = [UInt8](count: 16, repeatedValue: 0) 
UIDevice.currentDevice().identifierForVendor!.getUUIDBytes(&uuidBytes) 
let uuidData = NSData(bytes: &uuidBytes, length: 16) 
1

夫特3版本:

let vendorId = UIDevice.current.identifierForVendor! 
let uuidBytes = Mirror(reflecting: vendorId.uuid).children.map { $0.1 as! UInt8 } 
let data = Data(bytes: uuidBytes)