Your MyRowNames_Acc should be of type TArray<FName>, so did you set this one correctly?
If so, this is already an array, you do not really need to check for ‘if (rownames)’. A check for the array size could be done, I added this below: ‘rownames.Num()’. But it is not needed, as the iteration in the for loop will handle this.
Here’s some working example, just printing the row names…
LoadingScreenDatatable = LoadObject<UDataTable>(NULL, TEXT("DataTable'/Game/Henry/DataTables/DT_Test2.DT_Test2'"));
if (LoadingScreenDatatable)
{
TArray<FName> rownames = LoadingScreenDatatable->GetRowNames();
if (rownames.Num() > 0) // not really needed to check!
{
for (auto& ArrayElement : rownames)
{
UE_LOG(LogHerb64, Display, TEXT("Rowname: %s"), *ArrayElement.ToString());
}
}
}
This “Array has changed…” error happens, if you change the array content while iterating over it. I looked at your code - indeed, you add items within the for loop.
You could try to iterate with a for (i =…) loop to avoid these issues.
See this forum thread.