Using Cast()

hey,
I’m trying to change properties of APostProcessVolume in the world programmatically.
I start with getting a TArray of PostProcessVolumes (IInterface_PostProcessVolume) in my world and then casting them to APostProcessVolume.
but I fail to use Cast correctly. I’m getting this error:

IntelliSense: no instance of
overloaded function “Cast” matches the
argument list
argument types are: (TIndexedContainerIterator *, FDefaultAllocator>, IInterface_PostProcessVolume *,
int32>)

header file:

#pragma once

#include "GameFramework/Actor.h"
#include "Interfaces/Interface_PostProcessVolume.h"
#include "Engine/PostProcessVolume.h"
#include "PostProcessManager.generated.h"

UCLASS()
class RS_4_7_API APostProcessManager : public AActor
{
	GENERATED_BODY()
	
protected:
	APostProcessVolume* PP_Main;

public:	
	// Sets default values for this actor's properties
	APostProcessManager();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;
};

Source File:

#include "rs_4_7.h"
#include "PostProcessManager.h"


// Sets default values
APostProcessManager::APostProcessManager()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	//PP_Main = GetWorld()->PostProcessVolumes;
}

// Called when the game starts or when spawned
void APostProcessManager::BeginPlay()
{
	Super::BeginPlay();
	TArray<IInterface_PostProcessVolume*> PPVList = GetWorld()->PostProcessVolumes;
	
	for (auto Itr(PPVList.CreateIterator()); Itr; Itr++){
		if (Itr){
			this->PP_Main = Cast<APostProcessVolume>(Itr);
		}
	}
}

// Called every frame
void APostProcessManager::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

}

the error is on this line:

this->PP_Main =
Cast(Itr);

I understand I am not using the cast correctly, but what exactly?

another question about my code:

when I debug, it seem the code does not enter the for loop. but the TArray as one item.

thanks.

Try use foreach instead of iterator like this:

TArray<AActor*> Actors;
for (AActor* Actor : Actors)
{
    Actor->SetActorLocation(NewLocation);
}

More about range-based for loops here: RANGE-BASED FOR LOOPS

Have you tried using:

this->PP_Main = Cast<APostProcessVolume*>(*Itr);

instead?
Have a look at A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums