2013-10-03 19 views

Odpowiedz

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

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

Swift 2 wersja:

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

Swift 3 Wersja:

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