添加后delphi TCollection计数不增加

时间:2010-08-09 05:36:02

标签: delphi delphi-7 tcollection townedcollection

我有类型

  • TNotifyReply = class(TCollectionItem)
  • TNotifyReplylist = class(TOwnedCollection)

NotifyReplylist:= TNotifyReplylist.Create(self,TNotifyReply);

调用此函数(任意次数)后,将其计数为零

function TNotifyReplylist.addItem: TNotifyReply;
 begin
   Result := inherited Add as TNotifyReply;
   OutputDebugString(PAnsiChar('Count > '+ inttostr(count)));
 end;

有什么想法在这里发生?

1 个答案:

答案 0 :(得分:4)

发现问题,TNotifyReply.Create是

constructor TNotifyReply.Create(ACollection: TCollection);
begin
  inherited Create(Collection);
  ....

更改为

inherited Create(ACollection);