Hi Community,
I need to iterate over objects that Implement certain Interface.
I have seen that there’s a solution in blueprints:
I’d be great having something like:
for (TInterfaceIterator<ISavable> SaveActorItr(World); SaveActorItr; ++SaveActorItr)
{
FSaveLoadInitClassData InitCD = SaveActorItr->GetSaveLoadInitClassData();
ToBinary << InitCD;
ToBinary << **SaveActorItr;
}
I have seen this solution, from the awesome Rama, but It seems to me that there must be a rather elegant way of doing it.
IToStringInterface* TheInterface = NULL;
for ( TObjectIterator<AActor> It; It; ++It )
{
//Try InterFaceCasting
TheInterface = InterfaceCast<IToStringInterface>(*It);
//Run the Event specific to the actor, if the actor has the interface
if(TheInterface) ClientMessage(TheInterface->ToString());
}
Any ideas?
Thanks very very much.
Cheers,
Bullyproof