ByteBuffer wrap () equivalent in swift

0

Someone knows what is the equivalent of this java code in swift 2.3

ByteBuffer tmpCounter = ByteBuffer.wrap(byteCounter);
System.out.println(tmpCounter.getLong());
    
asked by Sergio Aldo Mejía Rodríguez 26.12.2016 в 22:59
source

1 answer

0

Well I already solved the equivalent to the byteByffer.wrap () would be in swift the following.

 // Algoritmo equivalente a byteBuffer.wrap() de java
    let array : [UInt8] =  [0,0,0,0,0,0,62,62]; // tu array of bytes
    var value : Int = 0;
    for byte in array {
        value = value << 8;
        value = value | Int(byte);
    }
print(value);
    
answered by 02.01.2017 / 20:57
source