TArray garbage collected?

Hello, this is my code

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = MultiArray)
TArray<UMultiArrayRow*> Rows;

UFUNCTION(BlueprintCallable, Category = MultiArray)
void AddNewRow()
{	
	UPROPERTY()
	UMultiArrayRow* NewItem = NewObject<UMultiArrayRow>();
		
	Rows.Add(NewItem);
}

When I call AddNewRow() and then I access Rows.Num() it always gives me 0

Is it automatically garbaged? or did i do something wrong?

You can remove the UPROPERTY() macro from the AddNewRow() body. I was able to get multiple rows as the attached screen shot shows, my question would be, what are you keeping the TArray Rows in? If it is in an object that is getting created/destroyed, then you are probably looking at a new instance of the Rows each time you create your holding object, which would be empty.

I would check that first. Maybe put your Rows in a longer lasting object?

Hello, thanks for the reply

I use it in blueprint, and i don’t think they are new instances since it is a variable

Here’s how i used it

and the results:

48739-capture2.jpg

Did i do something wrong?

You haven’t spawned an instance of your TileData. At this point TileData is just a variable to hold an instance, you need to spawn an instance and set your varialble, like so:

Ah!!! I see I forgot that

Thanks a lot!