How do you cast a UInt64 to an Int64?

前端 未结 6 1425
我在风中等你
我在风中等你 2020-12-17 23:08

Trying to call dispatch_time in Swift is doing my head in, here\'s why:

 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC), dispatch_get_mai         


        
6条回答
  •  长情又很酷
    2020-12-17 23:48

    Try this:

    let x:UInt64 = 1000 // 1,000
    let m:Int64 = 10 * Int64(x) // 10,000
    

    or even :

    let x:UInt64 = 1000 // 1,000
    let m = 10 * Int64(x) // 10,000
    let n = Int64(10 * x) // 10,000
    let y = Int64(x) // 1,000, as Int64 (as per @Bill's question)
    

    It's not so much casting as initialising with a separate type...

提交回复
热议问题