Help! I'm trying to write a wrapper and make a b4i library, but I failed to receive the events from OC side, i.e. the B4i code in "Sub tt_Event2" will not hit.
Could any one tell me what's wrong?
The header file looks like:
The .m file looks like:
And the b4i module looks like:
I have uploaded the whole project as attached. Please help!!!
Could any one tell me what's wrong?
The header file looks like:
B4X:
#import <Foundation/Foundation.h>
#import "iCore.h"
//~shortname:test_event
//~event:Event1 (text As String)
//~event:Event2
//~event:EventError (msg As String)
//~version:1.09
@interface test_event : NSObject
@property(nonatomic, copy) NSString* text;
@property(nonatomic) int intVar;
- (void)Initialize:(B4I *)bi :(NSString *)EventName;
- (void)setSomeTextValue:(NSString *)someText :(int)someIntValue;
- (void)doSomeOtherThings:(int)intValue2plus;
- (int)getIntValue;
- (NSString *)getSomeTextValue;
@end
The .m file looks like:
B4X:
#import "test_event.h"
@implementation test_event
- (void)Initialize:(B4I *)bi :(NSString *)EventName {
[B4IObjectWrapper setBIAndEventName:self :bi :EventName];
[B4IObjectWrapper raiseEvent:self :@"_event2" :@[]];
[B4IObjectWrapper raiseEvent:self :@"event2" :@[]];
[B4IObjectWrapper raiseEvent:self :@"Event2" :@[]];
NSLog(@"test_event initialized. self is %@ bi is: %@ EventName is: %@", self, bi, EventName);
NSLog(@"%@",self.debugDescription);
}
- (void)setSomeTextValue:(NSString *)someText :(int)someIntValue {
NSLog(@"enter setSomeTextValue");
_intVar = someIntValue;
_text = someText;
[B4IObjectWrapper raiseEvent:self :@"_Event2" :nil];
NSLog(@"after raise event 2");
}
- (void)doSomeOtherThings:(int)intValue2plus {
_intVar = _intVar + intValue2plus;
NSLog(@"intVar is: %d", _intVar);
// NSLog(@"event name is : %@", [B4IObjectWrapper getEventName:self]);
[B4IObjectWrapper raiseEventFromDifferentThread:self :@"_Event1:" :@[@"event from different thread"]];
[B4IObjectWrapper raiseEvent:self :@"_Event1:" :@[@"event from test_event."]];
NSLog(@"after raising event 1 ");
}
- (int)getIntValue {
NSLog(@"getIntValue: %d", _intVar);
return _intVar;
}
- (NSString *)getSomeTextValue {
NSLog(@"getIntValue: %d", _intVar);
return _text;
}
@end
And the b4i module looks like:
B4X:
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
Dim tt As test_event
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
Page1.RootPanel.LoadLayout("test_event")
NavControl.ShowPage(Page1)
tt.Initialize("tt")
End Sub
Sub tt_Event2
Msgbox("asdfasfd", "asfasdf")
End Sub
I have uploaded the whole project as attached. Please help!!!