Vik Singh
Vik Singh

Reputation: 1603

GCDASyncScocket readDataToLength: with swift

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.

Upvotes: 0

Views: 328

Answers (1)

Martin R
Martin R

Reputation: 540075

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)

Upvotes: 3

Related Questions