iOS Question Callbacks with IOS

Discussion in 'iOS Questions' started by davemorris, Aug 9, 2019.

Tags:
  1. davemorris

    davemorris Member Licensed User

    Hi, Guys

    How do you handle Callbacks in IOS - I am converting code from B4A to B4I

    The B4A code is
    Code:
    ' Timeout trips - hide the progress dialog and raise a Timeout event.
    Sub tmrProgressTimeout_Tick()
        
    Log("Timeout tripped")
        Hide
    #if B4A
        
    If SubExists(mCallback, mEvent & "_Timeout"Then
            
    CallSub(mCallback, mEvent & "_Timeout")
        
    End If
    #else
        
    'TODO <<< Put the B4I callback here!
    #End If

    End Sub
    Any ideas?

    Kind regards
    Dave
     
  2. Brandsum

    Brandsum Well-Known Member Licensed User

    your callback code will also work in b4i. so there is no need to check whether the ide is b4a or not
    Code:
    ' Timeout trips - hide the progress dialog and raise a Timeout event.
    Sub tmrProgressTimeout_Tick()
        
    Log("Timeout tripped")
        Hide

        
    If SubExists(mCallback, mEvent & "_Timeout"Then
            
    CallSub(mCallback, mEvent & "_Timeout")
        
    End If

    End Sub
     
  3. davemorris

    davemorris Member Licensed User

    Hi Brandsum

    Thanks, I am sorry I should of tried that before I asked the question - Just got it into my head the a different OS would need a different callback system.

    Regards
    Dave
     
  4. klaus

    klaus Expert Licensed User

    For B4i, you need to use this code:
    Code:
    ' Timeout trips - hide the progress dialog and raise a Timeout event.
    Sub tmrProgressTimeout_Tick()
        
    Log("Timeout tripped")
        Hide

        
    If xui.SubExists(mCallback, mEvent & "_Timeout"0Then
            
    CallSub(mCallback, mEvent & "_Timeout")
        
    End If

    End Sub
    The SubExist method in B4i needs a 3 third parameter, NumberOfArguments.
    This implemented in the xui.SubExists method, compatible for all three products.
     
    Erel and Brandsum like this.
  5. davemorris

    davemorris Member Licensed User

    Hi, Klaus
    Thanks for the input - yes that does appear to work.
    For the benefit of someone reading this post (and is not familiar with B4X) then to use xui.SubExists() you will need to insert in Process_Global (or in my case the Class_Global) Sub as shown below, and remember to tick XUI (or iXUI if using B4I) in the library manager.
    Code:
    Sub Class_Globals
        
    Private xui As XUI
    Kind regards
    Dave
     
    Erel likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice