Swift: gettimeofday and Unsafe Pointers

后端 未结 1 853
傲寒
傲寒 2021-01-21 00:22

The code in Swift

...
var time:timeval?
gettimeofday(UnsafePointer, UnsafePointer<()>) // this is the method expansion before filling in any         


        
相关标签:
1条回答
  • 2021-01-21 01:00

    I know one way to do it and this is as follows:

    var time:timeval = timeval(tv_sec: 0, tv_usec: 0)
    gettimeofday(&time, nil)
    

    I had to initialize time with something so there actually was a struct at the address &time pointed to.

    0 讨论(0)
提交回复
热议问题