Delphi Compiler Error
E2584 Weak attribute only allowed on fields and variables of type class or interface: ‘%s’
Reason for the Error & Solution
This occurs whenever weak references are used with arrays or any other types other than classes and interfaces.
TMyComponent = class
private
[Weak] GiveMe: array of Integer; // error, an array cannot be weak.
end;
This can be fixed by using the weak reference with a class instead:
TMyComponent = class
private
[Weak] TS: TStringList; // it’s ok, a class can be weak
end;