I use the below code for print date and time every 2 second. but Repeat run inside code 2 time in each fire.
private var timer: Repeater?
self.timer = Repeater.every(.seconds(2)) { _ in
print("App from \(from) => \(String(self.gf.getCurrentDateTime()))")
}
Result in console is here:
App from vcChatMain => 20181130135222
App from vcChatMain => 20181130135222
App from vcChatMain => 20181130135224
App from vcChatMain => 20181130135224
App from vcChatMain => 20181130135226
App from vcChatMain => 20181130135226
App from vcChatMain => 20181130135228
App from vcChatMain => 20181130135228
As you see, every 2 second, print method fire 2 time. Why this problem occurred?
I use the below code for print date and time every 2 second. but Repeat run inside code 2 time in each fire.
private var timer: Repeater?self.timer = Repeater.every(.seconds(2)) { _ inprint("App from \(from) => \(String(self.gf.getCurrentDateTime()))")}Result in console is here:
App from vcChatMain => 20181130135222App from vcChatMain => 20181130135222App from vcChatMain => 20181130135224App from vcChatMain => 20181130135224App from vcChatMain => 20181130135226App from vcChatMain => 20181130135226App from vcChatMain => 20181130135228App from vcChatMain => 20181130135228As you see, every 2 second,
printmethod fire 2 time. Why this problem occurred?