FreeAndNil(selectedobject);
but note that that will also free the corresponding Target[x], so you'll now have to add tests for that everywhere you use it, like in:
if Assigned(target[i]) then ...
If you only want to let
selectedobject pointing to nothing just do:
selectedobject := Nil; and let the objects destruction to the destructor of the array/list object or to the
OnClose event handler of the form or whatever.
do I have to use a dummy?
Well, that's basically what
FreeAndNil() does. Nothing wrong with that
BTW, instead of
Object.Destroy you should get used to calling
Object.Free. That's the (more) conventional way to dispose of an object, if for nothing else than because it checks whether the instance is assigned before itself calling destroy.