So, I have a dataprovider that, when the module isn’t be used, is set to an empty arrayCollection. Then, when the module is ready to be used, the dataprovider is changed to an array collection full of data. For some reason, another one of my functions is having problems with this. I keep getting the following error:
Cannot access a property or method of a null object reference
The following is the line of code causing the error:
for (i = 0; i < pickupPhoto.length; i++)
Is there any way I can make sure that pickupPhoto has a length property before calling this for loop? I tried the following, but I got the same error:
if (pickupPhoto.hasOwnProperty("length"))
Also tried:
if (pickupPhoto.length)
Thanks in advance,
Brds
Your problem is not that “length” doesn’t exist, but that pickupPhoto is actually null. But, you can check for both: