【发布时间】:2012-02-05 15:17:03
【问题描述】:
我正在尝试开始使用 spring4d 的集合部分。但我无法订阅集合更改事件。得到错误:[DCC Error]: E2008 Incompatible types at:
var
TestList: TObjectList<TObject>;
begin
... List initialization code ...
TestList.OnNotify.Add(TestHandler); <--- Error here
end
TObjectList 的 OnNotify 属性声明为:
property OnNotify: ICollectionNotifyDelegate<T>,在哪里
ICollectionNotifyDelegate<T> = interface(IMulticastEvent<Generics.Collections.TCollectionNotifyEvent<T>>)
end;
即OnNotify.Add 方法需要一个 Generics.Collections.TCollectionNotifyEvent,它声明为:
TCollectionNotifyEvent<T> = procedure(Sender: TObject; const Item: T;
Action: TCollectionNotification) of object;
我的事件处理程序声明为:
procedure TTestClass.TestHandler(Sender: TObject; const Item: TObject; Action: TCollectionNotification);
begin
end;
我很困惑 %) 请帮忙)
【问题讨论】: