Search code examples
androidiosdelphideprecateddelphi-10.2-tokyo

TList deprecated when compiling for any mobile device


I have a Delphi mobile app that contains the following declaration:

TWJInformationList = class(TList)

When I compile this app for any mobile device (Android, iOS Device 32 bit, iOS Device 64 Bit, and iOS Simulator), I get the following warning:

[DCC Warning] WJInformation.pas(248): W1000 Symbol 'TList' is deprecated

The above compiles fine on all other Target Platforms (32 bit and 64 bit Windows, and OSX).

What am I missing?


Solution

  • On all ARC-based platforms, which include Android, iOS, and Linux 1 (which is not a mobile platform), the old Pointer-based containers, like Classes.TList and containers in the System.Contnrs unit, are deprecated because they are not safe to use with ARC-based object/interface pointers. You need to use the newer Generics-based counterparts in the System.Generics.Collections unit, like TList<T>, so the compiler can manage ARC correctly. A direct replacement for TList would be TList<Pointer> if you don't want/need ARC handling.

    1: and maybe Windows in the future.