I need to store a temporary list of records and was thinking that a TList would be a good way to do this? However I am unsure how to do this with a TList<
We've just run into a similar issue here with a generic list of records. Hope the following psuedo code helps.
type
PPat = ^TPat;
TPat = record
data: integer;
end;
...
var
AList: TList;
...
procedure TForm1.Button1Click(Sender: TObject);
var
obj: PPat;
begin
obj := AList[0];
obj.data := 1;
Assert(obj.data = AList[0].data); // correct
end;
procedure TForm1.FormCreate(Sender: TObject);
var
obj: PPat;
begin
AList := TList.Create;
GetMem(obj, SizeOf(TPat)); // not shown but need to FreeMem when items are removed from the list
obj.data := 2;
AList.Add(obj);
end;