iOS Question Call B4i sub from inline OBJC and return value

CaptKronos

Active Member
Licensed User
How would I call from inline OBJC a B4i sub such as the following and have the inline code receive the sub's return value:
B4X:
sub test as int
   return 1
end sub
Thanks.
 

CaptKronos

Active Member
Licensed User
Do you mean like this:
B4X:
sub test as int
   return 1
end sub

#If OBJC 

-(NSInteger)testGettingVal
{
    NSInteger aNum;
    aNum=[self.bi raiseEvent:nil event:@"test:" params:@[]];
    return aNum;
}

#end if
I always get a value of 0 returned. I thought raising an event returned immediately (hence 0 rather than 1 being returned).
 
Upvote 0

CaptKronos

Active Member
Licensed User
Yes, sorry, you are correct. I rewrote my code on the fly to simplify it for the post and I missed the ":". My original code was passing a parameter. I also get the unexpected synchronous event message in the logs. However, I can't use raiseUIEvent because I believe that doesn't return a value.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
I know nothing about Objective C. But, as I understand, inline OBJC allows direct calls like in other languages. For example, I added some statements in Erel's sample (see test.zip).
 

Attachments

  • test.zip
    1.1 KB · Views: 229
Upvote 0
Top