For example, let's say I have a class TConfiguracao
.
Here the constructor and destructor attributes
and in some forms I create several T-type variables
conf1 :TConfiguracao;
conf2 :TConfiguracao;
...
conf1 := TConfiguracao.Create();
conf2 := TConfiguracao.Create();
...
In closing this form I do:
FreeAndNil(conf1);
FreeAndNil(conf2);
It is running 100%. What I would like to know is, is there any way to go through all the objects of this TConfiguracao
class and apply a FreeAndNil
without knowing for sure how many variables of this type I created? I know there is a way to traverse the components of a form this way
for i := 0 to Form.ComponentCount - 1 do
begin
if Form.components[i].classtype is TEdit then
begin
//
end;
end;
But objects from other classes I can not. Is there any way to do this ??