Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Nav.ShowPage(Page1)
Dim no As NativeObject = Me
no.RunMethod("methodThatRaiseEvent", Null)
End Sub
Sub Some_Sub(x As Int)
Log(x)
End Sub
#If OBJC
- (void)methodThatRaiseEvent {
[self.bi raiseEvent:nil event:@"some_sub:" params:@[@10]];
}
#End If
Note that the sub name in the raiseEvent call must be lower cased.
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Nav.ShowPage(Page1)
Dim no As NativeObject = Me
no.RunMethod("methodThatRaiseEvent", Null)
End Sub
Sub Some_Sub(x As Int)
Log(x)
End Sub
#If OBJC
- (void)methodThatRaiseEvent {
[self.bi raiseEvent:nil event:@"some_sub:" params:@[@10]];
}
#End If
Here's the actual code and the responses in the log:
B4X:
Sub Button2_Click
log("Clicked Me")
Try
Dim NativeMe As NativeObject = Me
NativeMe.RunMethod("test:", Array (True))
Catch
rlog("Last exception:" & LastException.Description)
End Try
End Sub
#If OBJC
- (void) test: (bool) on {
NSLog(@"this is a message");
[self.bi raiseEvent:nil event:@"olog:" params:@[@"Testing.."]];
}
#End If
Sub olog(msg As String)
Log(msg)
TextView1.Text=TextView1.Text & msg & CRLF
End Sub
This is the log;
Application_Start
Application_Active
Application_Active
Clicked Me
this is a message
Unexpected event (missing RaisesSynchronousEvents): olog:
Testing..