- Home /
arrays are giving me null reference exceptions and I don't know why
Hi, I'm my arrays are giving me alot of problems. I create an array and set it's size then I try to assign float's to it but I get a "NullReferenceException: Object reference not set to an instance of an object" error. here is the some of my code. Unity says the error is where secondArr is being assigned a variable for a the i'th position.
var firstArr:String[] = new String[length];
var secondArr:float[] = new float[length];
for(var i= 0; i < newDataParsed["data"].length; i++){
if(newDataParsed["data"][i][key] == key2){
firstArr[i] = newDataParsed["data"][i][key3];
secondArr[i] = newDataParsed["data"][i][key4];
}
Comment
Can you also post how you've instantiated and populated the newDataParsed array?
Best Answer
Answer by StephanK · Jan 03, 2013 at 07:54 PM
Probably your problem is not the secondArr but the newDataParsed array or whatever it is.
It was with newDataParsed. Took forver to figure out but it was full of null values that were messing things up.
Your answer
