# UPROPERTY is null

**URL:** <https://forums.unrealengine.com/t/uproperty-is-null/429984>\
**Category:** Blueprint\
**Tags:** UProperty, newobject, tsubclassof, unreal-engine, null, question\
**Created:** [July 22, 2018, 9:46am UTC](https://forums.unrealengine.com/t/uproperty-is-null/429984 "2018-07-22T09:46:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vetril](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vetril](https://forums.unrealengine.com/u/Vetril)\
**Post date:** [July 22, 2018, 9:46am UTC](https://forums.unrealengine.com/t/uproperty-is-null/429984/1 "2018-07-22T09:46:09Z")

</div>

Hi guys,

I’m trying to pass to a class that extends UButton a TSubclassOf UPROPERTY that points to a BP class. I then use this UPROPERTY to construct an instance through NewObject.

The problem I am having right now is that for some reason, at runtime the TSubclassOf is NULL and I don’t understand why. I guess it’s something really simple specific to UE4.

Could you have a look and let me know if you spot what I am doing wrong?

* * *

This is the (base) class of the classes that should be referenced by TSubclassOf.

```
// BBEvent.h

class UBBEvent;
class ABBHUD;

DECLARE_EVENT_OneParam(UBBEvent, FBBEvent, UBBEvent *)

UCLASS(Blueprintable, BlueprintType, DefaultToInstanced)

class SALTLAKECITY_API UBBEvent : public UObject
{
	GENERATED_BODY()

	...
};

```

This is the class that contains the UPROPERTY.

```
//BBButton.h

class UBBEvent;

UCLASS()

class SALTLAKECITY_API UBBButton : public UButton
{
	GENERATED_BODY()
	
	public:
		UBBButton(const FObjectInitializer & ObjectInitializer);

		virtual void PostInitProperties() override;
		
		...

	protected:
		UPROPERTY(Category = "Event Handler", BlueprintReadWrite, EditAnywhere, meta = (AllowPrivateAccess = "true"))
		TSubclassOf<UBBEvent> EventHandlerTemplate;

		UPROPERTY()
		UBBEvent * EventHandler;
};

```

This is how I try to use the UPROPERTY:

```
// BBButton.cpp

...

void UBBButton::PostInitProperties()
{
	Super::PostInitProperties();

	if (EventHandlerTemplate)
	{
		UE_LOG(LogTemp, Warning, TEXT("EventHandlerTemplate is not NULL"));
		EventHandler = NewObject<UBBEvent>(this, EventHandlerTemplate);
	}

	OnClicked.AddDynamic(this, &UBBButton::NotifyEventHandler);
}
...

```
