iOS Question __NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]

Alex_197

Well-Known Member
Licensed User
Longtime User
Hi all.

I'm trying to find out what is caused this error.

Here is my code - it show a google map for the client address.

Variable Main.SelectedClientAddress holds the client address.

B4X:
private Sub ShowMap
   
    Try
       
        Dim App As Application
        Dim urlMap As String="https://www.google.com/maps/search/"
        Dim su As StringUtils
        Dim Address As String
           
        Address=Main.SelectedClientAddress
               
        Address=Address.Replace(CRLF," ")
        Address=su.EncodeUrl(Address,"UTF-8")      
        urlMap=urlMap & Address
               
        If App.CanOpenURL(urlMap) Then
            App.OpenURL(urlMap)
        Else
            HUD.ToastMessageShow("Address cannot be shown",True)
        End If
    Catch
        Log("ShowMap " & LastException.description)
        Main.modFun.ShowError("UnscheduledClockIn_ShowMap " & LastException.description)
    End Try
   
End Sub

Thank you
 

Alex_197

Well-Known Member
Licensed User
Longtime User
Comment the Try / Catch elements and post the full error message.
I found what was the problem. The variable value that holds the clients address was null. That was very strange, I checked the query that pulls the data from the local db and I found this
B4X:
    MySQL=$"
        SELECT  distinct PS.ID, u.UserID ,FacilityID,pl.ProviderID,pl.ClientID,pl.ID as PlacementLocalID,
 pl.MatchupID,ps.JobDate,Shift,cl.FullName ,start,OriginalStart,OriginalFinish,
 pa.PAID,PA.Restrictions,cl.Distance,ScheduleMonitoring,u.UserName,U.Password,ProviderTypeID,RegKey,PA.PayeeID
FROM tblUsers as U
 INNER JOIN tblMobileUserAccounts as MA on u.UserID=ma.UserID
 inner JOIN tblPlacement as PL on ma.ProviderID=pl.ProviderID
 inner JOIN tblPlacementSchedule as PS on pl.id=ps.PlacementLocalID
 INNER JOIN tblClients as CL on Cl.ClientID=pl.ClientID
 INNER JOIN tblPriorAuthorization as PA on pa.PAID=ps.PAID
where start is not null
and Finish is null
And julianday(date('now','localtime'))-julianday(Date(substr(ps.JobDate, 7,4) || '-' || substr(ps.JobDate, 1,2) || '-' || substr(ps.JobDate, 4,2)))<=7;
        "$
        
    rs=Main.SQL1.ExecQuery(MySQL)
        
        Do While rs.NextRow
                
            Main.SelectedClientAddress=rs.GetString("Address")
            
        Loop       
        
        rs.close

As you can see there is no field Address in this query and when I run the code it doesn't crash with the error No such field Address or something like this but assigns a null value to the variable.

Is it normal?
 
Upvote 0
Top