Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ames!eos!shelby!polya!ali From: ali@polya.Stanford.EDU (Ali T. Ozer) Newsgroups: comp.sys.next Subject: Re: copying Controls (Buttons) Message-ID: <10884@polya.Stanford.EDU> Date: 26 Jul 89 14:54:46 GMT References: <23996@labrea.Stanford.EDU> Sender: Ali T. Ozer Reply-To: aozer@NeXT.com (Ali T. Ozer) Organization: . Lines: 21 In article <23996@labrea.Stanford.EDU> Dave Combs writes: >I've consistently run into a problem when I copy something like a Button >object, which contains a cell of another class (Controls do this a lot). >The problem is that when the Button is copied, the ButtonCell that it >contains is not. If I subsequently free the copied Button, I lose the >ButtonCell, and my initial Button dies if I try to use it. "copy" is supposed to make a copy of only the top level object; all referenced objects are shared. There's another method, "deepCopy," I believe, that duplicates the whole tree of objects. Problem with copy is that it's not always enough, as in the case of Button. Problem with deepCopy is that you might end up with more than you need --- on deepCopy of a view, for instance, you might find yourself with two windows. You want a "functionalCopy," which is not provided. Most AppKit objects are too complex for a simple "copy" or "deepCopy" to suffice. Ali Ozer, NeXT Developer Support aozer@NeXT.com