settimeofday parameters

I'm trying to execute the settimeofday function.


Here is the declaration of the function:


settimeofday(UnsafePointer<timeval>, UnsafePointer<timezone>)


I don't know how to read that. What do those parameters mean? What do I pass as arguments?

Accepted Answer

`UnsafePointer<T>` is a pointer type in Swift, pointer to T.

And `timeval` and `timezone` are C-structs imported to Swift.


Declare a variable of type T (in your case `T` is `timeval` or `timezone`), and pass it as an inout parameter, meaning prefix '&'.

        var tv = timeval()
        //setup tv.
        var tz = timezone()
        //setup tz.
        settimeofday(&tv, &tz)
settimeofday parameters
 
 
Q