So the setup would be something like Dictionary (like the kind that you flip through to look up a word) and Word. The Dictionary contains all of its Words, and the Word wants to refer back to a property of its Parent Dictionary, is that it?
Set up the Constructor of ClassB (the Word in my example) so it takes ClassA (the Dictionary) as a parameter. The Constructor will store that reference to ClassA so you can refer to it direction, but do not store it directly. If you do, you will set up a circular reference and create a memory leak.
Instead, create a computed property, Parent As ClassA, and a private property, mParent As WeakRef. In the Constructor, you will:
mParent = new WeakRef( givenClassA )
In the Parent.Get, you will:
if mParent is nil then return nil
dim o as Object = mParent.Resolve
if o is nil then return nil
return ClassA( o )
As long as Dictionary continues to exist somewhere else, Parent will never return nil. Once Dictionary ceases to exist, presumable so will all its Words, so you should still never get nil. (But you should always check for nil anyway, just in case.)
hmm i am getting a little confused. i guess i will have to read up on it more.
this is the exact thing i have…
i have a class leftbaritem (no super) with a few properties. one integer property is named myid
another of the properties named folder is a class cabinetfolder ( no super ) and that property has a method named build
when i run that method as leftbaritem.folder.build i want to be able to in that method get the myid of the leftbaritem
leftbaritem being created with (dim item as new leftbaritem) and being assigned to a rowtag in a listbox.
on a side note. how do i become verified on here? i bought the desktop version.