"WeakRef is deprecated. You should use WeakRef instead"

Xojo 2020 is telling me that something is deprecated for some WeakRefs. But I can’t make the changes work. The original code is:

MyStackController = WeakRef.Create(stackView)

where MyStackController is a WeakRef. Adapted from the docs (who makes that super odd code in the docs???) the following works:

Dim f As New FolderItem
f.Name = "TestFile.txt"
Dim ref As New WeakRef(f)

Changing my code to

MyStackController = new WeakRef(stackView)

I get an error message “Too many arguments, got 1, expected 0”. What am I missing here?

Found the problem. There was a “using clause”. After taking that out I was able to change the code to API 2.

1 Like

You must have a Using declaration that is forcing the Xojo namespace.

Edit: D’oh!

1 Like

Grin… great minds think alike. The error message wasn’t really good. And I would never use a “using clause” in my own code.

2 Likes