iOS Question Timer inside a Class

narek adonts

Well-Known Member
Licensed User
Longtime User
I didnt understood.
The following code is inside a Class

B4X:
Sub Class_Globals
    Dim tmrShow As Timer
   
End Sub


Public Sub Initialize(eventName As String, Inter As Int,color As Int,Receiver As Panel)
   
    tmrShow.Initialize("tmrShow",Inter)

    tmrShow.Enabled=True
    pnlReceiver=Receiver
    CircleColor=color
    EventStr=eventName
    cInterval=Inter
   
End Sub

Private Sub TmrShow_Tick
Log("tick")
End Sub

It doesnt work
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
This works with a timer in a class, check your code against this one:
 

Attachments

  • TimerClass.zip
    1.3 KB · Views: 197
Upvote 0

narek adonts

Well-Known Member
Licensed User
Longtime User
Upvote 0

stevel05

Expert
Licensed User
Longtime User
If you declare a reference to the class as a local variable, then it is likely that the class will be destroyed once the sub it's declared in is completed. You will need to hold a reference in a Global variable or a collection that is a Global variable (Array,List or Map) for the class instance to persist.
 
Upvote 0
Top