How to make UObject in Blueprint

Hello,

I wonder how do you make custom static function to make UObject in blueprint in 4.8

I’ve tried:

////////////////.h

 UFUNCTION(BlueprintCallable, Category="Objects")
 static UObject* SpawnObject(UClass* ObjClass);

/////////////.cpp

 UObject* ASomeClass::SpawnObject(UClass* ObjClass) 
{
        return ConstructObject(ObjClass);
 }

and

////////////////////.cpp

UObject* ASomeClass::SpawnObject(TSubclassOf<UObject> Obj)
{
	UObject* tempObject = NewObject<Obj>();
	return tempObject;
}

they are both not working.
Can someone tell me the right way? It said ConstructObject has been deprecated in UE4.8
Thanks

Use NewObject same as SpawnActor:

NewObject<Obj>(Obj::StaticClass());

Hello, thanks for the reply

I tried your solution this one

UObject* UMyBlueprintFunctionLibrary::SpawnObject(UClass* boom) {
	UObject* newItem = NewObject<boom>(boom::StaticClass());
	return newItem;
}

and this one

UObject* UMyBlueprintFunctionLibrary::SpawnObject(TSubclassof<UObject> boom) {
	UObject* newItem = NewObject<boom>(boom::StaticClass());
	return newItem;
}

I got same errors for both of them:
error C2653: ‘boom’ : is not a class or namespace name

Did i do something wrong?

I tinkered around and change boom::StaticClass() to boom->StaticClass() and still not working. The problem is located in NewObject

Here:

UObject* UMyBlueprintFunctionLibrary::SpawnObject(UClass* boom) {
	return NewObject<boom>();
}

The Error is in

error C2974: ‘NewObject’ : invalid template argument for ‘T’, type

when I tried:

UObject* UMyBlueprintFunctionLibrary::SpawnObject(UClass* boom) {
	return NewObject<UClass>();
}

it is working but it is not the right way to spawn object right?

I found out the answer

    UObject* UMyBlueprintFunctionLibrary::SpawnObject(UClass* ObjClass)
    {
         return NewObject<UObject>(NULL, ObjClass);
    }

UObject*
AahsanActorBPFunctionLibrary::
NewObjectFromBlueprint(UObject* owner, UClass* UC)
{
UWorld* World = GEngine->GetWorldFromContextObject(owner);//???why nthis needed
UObject* tempObject = NewObject(UC);

		return tempObject;

		
	}