You could try to have a reference to a base class instead of the real class. It's a bit hard to explain so I'll just throw in the code:
[pascal]
TMyClass = class
private
FMyOtherClass: TObject;
public
procedure SetMyOtherClass(Value: TObject);
end;
implementation
uses
someunit;
procedure TMyClass.SetMyOtherClass;
begin
Assert(Value is TMyOtherClass, 'Value need to be a TMyOtherClass reference');
FMyOtherClass := TMyOtherClass(Value);
end;
[/pascal]
Sometimes it works good by doing it that way other times it don't, all depending on you own special needs.
As for a global reference. You could use a singleton (which can only have one instance) instead of it. In the end it's the same thing but it looks better and are probably a bit more stable.
Bookmarks