I've started to use the TCollection class in Delphi XE and I found the answer at Using TOwnedCollection descendant in Delphi to be a good starting point. TCollection manages a list of TCollectionItems. However I noticed that TCollection.Add doesn't seem to add an TCollectionItem to a Collections array and indeed my testing appears to confirm that. The code in TCollection itself is:
function TCollection.Add: TCollectionItem;
begin
Result := FItemClass.Create(Self);
Added(Result);
end;
FItemClass is the object type that will be created and I thought added to the TCollection object. The Added() method is deprecated and appears to be an old notification method. Nowhere do I see the Result being added to the collection. How should one add a TCollectionItem to a TCollection?