timer - Swift Countdown from game end + 1 hour -


i trying create timer between games, after user loses life must wait 5min until can play again. not sure best way is.

i need safe against user editing time in settings.

what best way achieve this?

at moment going through process of setting nsdate() object in keychain:

let date = nsdate() 

and using values:

let date = gameactions["endfight"] as! nsdate         let calendar = nscalendar.currentcalendar()         let components = calendar.components([ .hour, .minute, .second], fromdate: date)         let hour = components.hour         let minute = components.minute          print("hour: \(hour)")         print("mins: \(minute)") 

however hour returns 1. after looking around lot occurred me might going whole wrong way.

i going reverse swift timer tutorial count down backwards..

is right track?

main question clarification:

how able determine if 5 mins has passed since last game fight?

the correct way utilizing timestamps on backend @ utc 0. cannot safeguard against user changing time on phone, don't rely on timestamps there.

if want prevent user having access feature x amount of time, log activity on backend.

then compare between 2 dates, try this:

let calendar = nscalendar.currentcalendar() let datecomponenets = calendar.components(nscalendarunit.minute, fromdate: serveractivitylogdate, todate: servercurrentdate, options: []) let minutes = datecomponenets.minute 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -