TObjectIterator
and TObjectRange
can be used to iterate UObjects. If you need to iterate actors, you should usually TActorIterator or TActorRange instead.
TObjectIterator
is an iterator, while TObjectRange
can be used in foreach loops. Other than that, they behave in the same way.
Gotchas
Not world filtered
Big gotcha: Object iterators and ranges are not world-filtered. They can return stuff from editor worlds in addition to the PIE world!
Iterating actor components
These iterators will include CDOs and other special objects. Using the following RF flags skips iterating them:
for(UFlowComponent* Comp : TObjectRange<UFlowComponent>(RF_ClassDefaultObject | RF_ArchetypeObject))