swift - Restore label to variables when switching back to a view -


i new swift , have been building timer app. main (first) view controller stopwatch.

recently, added view controller view splits stopwatch. problem occurs when timer has been or running , user switches second view controller , returns main view controller.

instead of displaying correct stopwatch time (for example: 12:34.56), label reset default text have stopwatch (00:00.00). if resume stopwatch, restarts left off (this how intend function since user has not manually reset watch).

how can display current time when switching stopwatch view controller?

you store current time in global variable before going split view. then, on viewdidappear method of original view, set label correct string based on stored in variable

for over-simplified example

//set "00:00.00" default var currenttime: string = "00:00.00"  override func viewdidappear(animated: bool){     mylabel.text = currenttime }  func gotosplitview(){     currenttime = mylabel.text } 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -