Bug? NativeObject with BOOL as return type

stevel05

Expert
Licensed User
These return 1 for true and 0 for false, the IDE complains that Types Do Not Match when testing for 0 or 1. (But it works)

Should probably return True or False for consistency.

Example:

upload_2014-11-17_14-56-6.png
 

stevel05

Expert
Licensed User
I just tried it, b is false whether the returned value is 0 or 1
 

Erel

Administrator
Staff member
Licensed User
You are correct.
This code will correctly convert the value:
B4X:
Sub GetBoolean(no As NativeObject, field As String) As Boolean
   Dim b As Object = no.GetField(field)
   Return b
End Sub
NativeObject.GetField returns a wrapped object. By assigning it to a variable of type object we can get the real object (number in this case). Then we convert it to boolean.
 

stevel05

Expert
Licensed User
OK Thanks, is there any harm in just testing for 0 and 1, even though the IDE complains?
 
Top