iOS Question [SOLVED] How to know if it's not needed to initialize?

Sandman

Well-Known Member
Licensed User
I have this code, which I believe is correct, even though the variable isn't initialized:

B4X:
    ' Check if we have access to the camera   
    Dim llc As LLCamera

    If llc.AuthorizationDenied Then
        Log("Fail")
    End If
The linter in the IDE gives me the error "Variable 'llc' was not initialized. (warning #11)".

I know that I can filter away the error by doing one of these:
B4X:
Dim llc As LLCamera 'ignore
#IgnoreWarnings: 11
But what I'm really wondering is if there is a way to know when an initialize is not needed? I can't find any mention in the documentation about this, and haven't been able to find anything in the forum either. (As a reference, here's a thread with code that clearly shows that AuthorizationDenied is tested before it's initialized.)

Bottom line is that I want to understand how this works so that I don't filter away real errors when I add the 'ignore
 

Erel

Administrator
Staff member
Licensed User
It should have been documented in this property that it can be used without initializing the object (assuming that there is such a use case). There is no other way to know it.
 
Top