TArrayMyIntArray; MyIntArray.Add(1); MyIntArray.Add(2); MyIntArray.Add(3); int32* IntArrayData = MyIntArray.GetTypedData(); for (int i = 0; i < MyIntArray.Num(); i++) { UE_LOG(LogTemp, Warning, TEXT("Int value: %d"), *(IntArrayData + i)); }
struct FMyStruct { int32 MyIntProperty; FString MyStringProperty; }; TArrayThis example creates a custom struct, adds 2 instances of it to an array, and retrieves a pointer to the data. The pointer is then looped through to print out each value of the custom struct. Package library: Unreal Engine C++.MyStructArray; MyStructArray.Add(FMyStruct{ 1, "Hello" }); MyStructArray.Add(FMyStruct{ 2, "World" }); FMyStruct* MyStructData = MyStructArray.GetTypedData(); for (int i = 0; i < MyStructArray.Num(); i++) { UE_LOG(LogTemp, Warning, TEXT("MyIntProperty: %d, MyStringProperty: %s"), MyStructData[i].MyIntProperty, *MyStructData[i].MyStringProperty); }