Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The Official Embarcadero documentation Wiki on the <a href="http://docwiki.embarcadero.com/VCL/en/Generics.Collections.TObjectList" rel="nofollow noreferrer">Generics.Collections.TObjectList</a> contains a simple code example of the <a href="http://docwiki.embarcadero.com/CodeSamples/en/Generics_Collections_TObjectList_(Delphi)" rel="nofollow noreferrer">TObjectList in action</a>.</p> <p>I'm not certain exactly what the question is driving at but to address the broad use of a TObjectList, the example initialisation code for a TObjectList might look like this: </p> <pre><code>var List: TObjectList&lt;TNewObject&gt;; Obj: TNewObject; begin { Create a new List. } List := TObjectList&lt;TNewObject&gt;.Create(); { Add some items to the List. } List.Add(TNewObject.Create('One')); List.Add(TNewObject.Create('Two')); { Add a new item, but keep the reference. } Obj := TNewObject.Create('Three'); List.Add(Obj); </code></pre> <p>The <a href="http://docwiki.embarcadero.com/CodeSamples/en/Generics_Collections_TObjectList_(Delphi)" rel="nofollow noreferrer">example code</a> should give you an idea of what the TObjectList can do but If I've understood the question correctly it seems that you would like to be able to add more than one class type to a single instance of the <a href="http://docwiki.embarcadero.com/VCL/en/Generics.Collections.TObjectList" rel="nofollow noreferrer">TObjectList</a>? A TObjectList can only be initiated with a single type so it might be better if you initiated the TObjectList with a Interface or Abstract class that is shared by all of the classes you wish to add to it. </p> <p>One important difference when using a <a href="http://docwiki.embarcadero.com/VCL/en/Generics.Collections.TObjectList" rel="nofollow noreferrer">TObjectList</a> compared to creating your own is the existance of the <a href="http://docwiki.embarcadero.com/VCL/en/Generics.Collections.TObjectList.OwnsObjects" rel="nofollow noreferrer">OwnsObjects</a> property which tells the <a href="http://docwiki.embarcadero.com/VCL/en/Generics.Collections.TObjectList" rel="nofollow noreferrer">TObjectList</a> whether it owns the objects you add to it and therefore consequently whether it should manage freeing them itself.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload