[fpc-pascal] casting interfaces and objects

Marco van de Voort marcov at stack.nl
Sun May 18 23:38:14 CEST 2008


> Am Sonntag, den 18.05.2008, 23:07 +0200 schrieb Marco van de Voort:

> begin
> 	if (fObservers.count<=0) then exit;
> 	for i:=0 to fObservers.count-1 do begin
> 		if ((fObservers[i] as IObserver)=obsv) then begin
> 			fObservers.delete(i);
> 			fObservers.pack;
> 			exit;

I think this works, assuning fobservers is an array or tlist of objects,
because you only go from object to interface, not from interface to object.



More information about the fpc-pascal mailing list