Swift - How do I display portions of an hour? -


i have label i'm updating every second shows hours 100ths of hour("1.67", etc.). i'm trying show correctly, having trouble.

    second = 781      let timeworked = float(second/3600)      let timeworkedinhours = (string(format:"%.02f", timeworked))      timeworkedlabel.text = "\(timeworkedinhours)" 

i've tried few things, nothing has worked yet. solutions?

i guess second defined int. define double instead. can rid of float cast too:

var second: double = 0 // ... let timeworked = second / 3600.0 

Comments

Popular posts from this blog

ios - Is 'init' forbidden as *part* of a variable name? -

file - Python: AttributeError: 'str' object has no attribute 'readlines' -

c# - Get the Class name in a class with atribute inside a attribute method -