iOS 获取设备的UUID

swift:

class func getUUID() -> String {
        let myUUID:CFUUIDRef = CFUUIDCreate(nil)
        let UUIDString:CFStringRef = CFUUIDCreateString(nil, myUUID)
        let resultString:String = CFStringCreateCopy(nil, UUIDString) as String
        print(resultString)
        return resultString
    }

OC:

-(NSString*) uuid {  
    CFUUIDRef myUUID = CFUUIDCreate( nil );  
    CFStringRef uuidString = CFUUIDCreateString( nil, myUUID );  
    NSString * result = (NSString *)CFStringCreateCopy( NULL, uuidString);  
    CFRelease(puuid);  
    CFRelease(uuidString);  
    return [result autorelease];  
}

你可能感兴趣的:(IOS,ios,swift)