Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private Swifter As NativeObject
End Sub
Private Sub Application_Start (Nav As NavigationController)
'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
Dim GetString As String = CallSwift("GetString",Null,Null).AsString
Log(GetString)
CallSwift("SetPageColor",Array("Col","Page"),Array(Swifter.ColorToUIColor(Colors.Magenta),Page1.RootPanel))
CallSwift("RaiseEvent",Null,Null)
End Sub
Sub RaiseMe (Info As String)
Log("Info: " & Info)
End Sub
Sub CallSwift(MethodName As String, ParamNames() As List, Params() As Object) As NativeObject
If Not(Swifter.IsInitialized) Then
Swifter = Me
Swifter = Swifter.RunMethod("InitSwifter",Null)
End If
If Not(ParamNames = Null) Then
Dim ArgsStr As String
For Each Arg As String In ParamNames
If ArgsStr = "" Then ArgsStr ="With"
If Arg.Length > 1 Then
ArgsStr = ArgsStr & Arg.SubString2(0,1).ToUpperCase & Arg.SubString(1) & ":"
Else
ArgsStr = ArgsStr & Arg.ToUpperCase & ":"
End If
Next
End If
Return Swifter.RunMethod(MethodName & ArgsStr,Params)
End Sub
#if objc
#import "B4iProject-Swift.h"
-(Swifter*)InitSwifter{
Swifter* SW = [[Swifter alloc] init];
[SW setSwifterWithB: self.bi];
return SW;
}
#End If
#if swift
func GetString() -> NSString{
return "Your text"
}
func SetPageColor (Col: UIColor, Page: UIView){
Page.backgroundColor = Col
}
func RaiseEvent() {
bi!.raiseEvent(nil, event: "raiseme:", params: ["very important"])
}
#End If