Hallo,
ich will einen Timer erstellen, der auch weiterläuft wenn die App im Hintergrund ist.
Soweit bekannt geht das nur über Umwege, in dem ich mir die aktuelle Zeit in eine Datei schreibe.
Sobald die App wieder in den Vordergrund tritt, lese ich die Zeit wieder aus der Datei, ermittle die Differenzzeit zur aktuellen Zeit, und addiere diese auf meinen Timer drauf. Dann sieht es so aus als ob der Timer weitergelaufen wäre.
Frage ist:
Wie mache ich das am besten?
Mein bissheriges Vorgehen:
Die Timerwert steht in einem UILabel-Text, welcher in einer Klasse "myController" definiert ist und auf einem View dargestellt wird.
In der Methode "applicationWillTerminate" in meinem ApplicationDelegate soll jetzt dieser UILabel-Text weggeschrieben werden.
Das Problem:
Diese Eigenschaft ist hier nicht bekannt, da in einer anderen Klasse definiert!
Wie greife ich jetzt am besten auf myLabel.text zu?
Der Zugriff auf eine Methode einer anderen Klasse (FileIO) wird hier ebenfalls durchgeführt und funktioniert auch.
Gruß
Chris
ich will einen Timer erstellen, der auch weiterläuft wenn die App im Hintergrund ist.
Soweit bekannt geht das nur über Umwege, in dem ich mir die aktuelle Zeit in eine Datei schreibe.
Sobald die App wieder in den Vordergrund tritt, lese ich die Zeit wieder aus der Datei, ermittle die Differenzzeit zur aktuellen Zeit, und addiere diese auf meinen Timer drauf. Dann sieht es so aus als ob der Timer weitergelaufen wäre.
Frage ist:
Wie mache ich das am besten?
Mein bissheriges Vorgehen:
Die Timerwert steht in einem UILabel-Text, welcher in einer Klasse "myController" definiert ist und auf einem View dargestellt wird.
In der Methode "applicationWillTerminate" in meinem ApplicationDelegate soll jetzt dieser UILabel-Text weggeschrieben werden.
Das Problem:
Diese Eigenschaft ist hier nicht bekannt, da in einer anderen Klasse definiert!
Wie greife ich jetzt am besten auf myLabel.text zu?
Der Zugriff auf eine Methode einer anderen Klasse (FileIO) wird hier ebenfalls durchgeführt und funktioniert auch.
Gruß
Chris