GCDASyncScocket readDataToLength: with swift

326 views Asked by At

I am trying to implement an app using GCDAsynSocket framework with Swift. I am stuck at GCDASyncSocket's readDataToLength method.

In objective c, we use to write it as following:

    [socket readDataToLength:sizeof(uint64_t) withTimeout:-1.0 tag:0];

Now, I am not sure how can I replace sizeof(uint64_t) in Swift.

1

There are 1 answers

3
Martin R On BEST ANSWER

It is almost similar in Swift, but unlike (Objective-)C, there are different keywords for taking the size of a type:

let size = sizeof(UInt64)

or the size of a value:

var x : UInt64 = 0
let size = sizeofValue(x)