You have:
let timeInterval: NSTimeInterval = getTimeInterval ()
let dispatch_time = dispatch_time (DISPATCH_TIME_NOW, Int64 (timeInterval * NSEC_PER_SEC))
And you get the following error:
ERROR: Binary operator '*' cannot be applied to operands of type 'NSTimeInterval' and 'UInt64'
As a result, you will need to translate or change the types of variables in your Int64(timeInterval * NSEC_PER_SEC) equation Int64(timeInterval * NSEC_PER_SEC) so that they have compatible data types.
timeInterval is an NSTimeInterval that is an alias of type DoubleNSEC_PER_SEC - UInt64dispatch_time function expects an Int64 argument
Therefore, the error will disappear by changing the value of NSEC_PER_SEC to a Double so that it matches the data type timeInterval .
let dispatch_time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeInterval * Double(NSEC_PER_SEC)))
Another random point: you will probably get the Variable used within its own initial value error when you name your dispatch_time variable when you call dispatch_time .
source share