iOS Question need help about ios library dev

icefairy333

Active Member
Licensed User
here is my code:
B4X:
//
//  firstlib.h
//  firstlib
//
//  Created by kaopuedu on 16/10/26.
//  Copyright © 2016年 kaopuedu. All rights reserved.
//
#import "iCore.h"
#import <Foundation/Foundation.h>
@class B4I;
//~shortname:firstlib
//~author:icefairy333
//~event:gotmsg(msg as String)
//~version:1.01
@interface firstlib :B4IObjectWrapper
- (void)Initialize:(B4I *)bi :(NSString *)EventName :(NSString *)param ;
@end
B4X:
//
//  firstlib.m
//  firstlib
//
//  Created by kaopuedu on 16/10/26.
//  Copyright © 2016年 kaopuedu. All rights reserved.
//

#import "firstlib.h"

@implementation firstlib
-(void)Initialize:(B4I *)bi :(NSString *)EventName :(NSString *)param{
    NSLog(@"testfunc:%@ param:%@",EventName,param);
    [B4IObjectWrapper setBIAndEventName:self :bi :EventName];//bind data
    [B4IObjectWrapper raiseEvent:self :@"_gotmsg" :@[@[param]]];
    [B4IObjectWrapper raiseEvent:self :@"_gotmsg" :@[@[@"constString"]]];
    NSLog(@"over");
}

@end
this is the b4i code:
B4X:
'Code module
#Region  Project Attributes
    #ApplicationLabel: firstlib
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #MinVersion: 7
#End Region

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 fb As firstlib
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("firstlib")
    Page1.Title = "第一个库"
    Page1.RootPanel.LoadLayout("layfirst")
    NavControl.ShowPage(Page1)
End Sub
Sub firstlib_BarButtonClick (Tag As String)
    Log("tag:"&Tag)
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
   
End Sub

Private Sub Application_Background
   
End Sub


Sub btncalllib_Click
    Log("btncalllib_Click")
    fb.Initialize("fb","testparam")
End Sub
Sub gotmsg(msg As String)
    Log("gotmsg:"&msg)
End Sub
Sub fb_gotmsg(msg As String)
    Log("fb_gotmsg:"&msg)
End Sub
and the log:
B4X:
Application_Start
Application_Active
btncalllib_Click
testfunc:fb param:testparam
over
the event can not be executed ,what's wrong with my code please?
 

icefairy333

Active Member
Licensed User
It should be @"_gotmsg:"
after add ":"
B4X:
//
//  firstlib.m
//  firstlib
//
//  Created by kaopuedu on 16/10/26.
//  Copyright © 2016年 kaopuedu. All rights reserved.
//

#import "firstlib.h"

@implementation firstlib
-(void)Initialize:(B4I *)bi :(NSString *)EventName :(NSString *)param{
    NSLog(@"testfunc:%@ param:%@",EventName,param);
    [B4IObjectWrapper setBIAndEventName:self :bi :EventName];//binddata
    [B4IObjectWrapper raiseEvent:self :@"_gotmsg:" :@[@[param]]];
    [B4IObjectWrapper raiseEvent:self :@"_gotmsg:" :@[@[@"constString"]]];
    NSLog(@"over");
}

@end
the log
B4X:
Copying updated assets files (1)
Application_Start
Application_Active
btncalllib_Click
testfunc:fb param:testparam
Unexpected event (missing RaisesSynchronousEvents): fb_gotmsg:
over
fb_gotmsg:(
    testparam
)
fb_gotmsg:(
    constString
)
how to solve this error please?
 
Top