Re: Initialize a subclass object with a base class object

2008-05-20 Thread Liviu Andron
On Tue, May 20, 2008 at 2:35 AM, [EMAIL PROTECTED] (!sic) wrote: I am not sure I understand the OP's question, but the shortest answer seems to be to override the super class's designated initializer. I think he wants an Objective-C equivalent to a C++ copy constructor. That is...

Re: Initialize a subclass object with a base class object

2008-05-20 Thread stephen joseph butler
On Tue, May 20, 2008 at 1:50 AM, Liviu Andron [EMAIL PROTECTED] wrote: setRepresentedObject: is a hint, thanks, but it doesn't resolve the problem either: he MUST copy every property from the original NSButtonCell (font, attributedTitle, imageDimsWhenDisabled, etc). This is how you will have

Re: Initialize a subclass object with a base class object

2008-05-20 Thread Nathan Kinsinger
On May 20, 2008, at 1:57 AM, stephen joseph butler wrote: My high-level goal: he wants an Objective-C equivalent to a C++ copy constructor You need to go a little higher. WHY do you need a C++ copy constructor? You talk about someone modifying your nib in IB. Why is someone doing this w/o

Re: Initialize a subclass object with a base class object

2008-05-20 Thread Liviu Andron
On Tue, May 20, 2008 at 10:57 AM, stephen joseph butler [EMAIL PROTECTED] wrote: On Tue, May 20, 2008 at 1:50 AM, Liviu Andron [EMAIL PROTECTED] wrote: setRepresentedObject: is a hint, thanks, but it doesn't resolve the problem either: he MUST copy every property from the original

Re: Initialize a subclass object with a base class object

2008-05-20 Thread Liviu Andron
On Tue, May 20, 2008 at 11:38 AM, Nathan Kinsinger [EMAIL PROTECTED] wrote: On May 20, 2008, at 1:57 AM, stephen joseph butler wrote: My high-level goal: he wants an Objective-C equivalent to a C++ copy constructor You need to go a little higher. WHY do you need a C++ copy constructor?

Re: Initialize a subclass object with a base class object

2008-05-20 Thread Erik Buck
1) NSCell is often used along with the Prototype design pattern. See the -setPrototype: method of NSMatrix. When so configured, NSMatrix copies its prototype cell as needed to create new instances. 2) Of course NSCell implements NSCoding. Otherwise it couldn't be used in Interface

Re: Initialize a subclass object with a base class object

2008-05-20 Thread Andy Lee
On May 20, 2008, at 6:17 AM, Liviu Andron wrote: On Tue, May 20, 2008 at 10:57 AM, stephen joseph butler [EMAIL PROTECTED] wrote: On Tue, May 20, 2008 at 1:50 AM, Liviu Andron [EMAIL PROTECTED] wrote: setRepresentedObject: is a hint, thanks, but it doesn't resolve the problem either: he

Re: Initialize a subclass object with a base class object

2008-05-20 Thread Andy Lee
On May 20, 2008, at 8:55 AM, Andy Lee wrote: You could add a category to NSObject like this: - (void)copyProperties:(id)otherObject (nitpicking myself) -copyPropertiesFrom: would be a better name. And I would add an ugly prefix to avoid collision in case Apple adds a method of the same

Initialize a subclass object with a base class object

2008-05-19 Thread Liviu Andron
Problem: I want to extend NSButtonCell (to keep some additional data) = MyButtonCell, but this MyButtonCell objects must be initialized with some base classes object @interface MyButtonCell: NSButtonCell { @private MyData* fData; } +(id)issueWithCell:(NSButtonCell*)cell; @end

Re: Initialize a subclass object with a base class object

2008-05-19 Thread Erik Buck
I am not sure I understand the OP's question, but the shortest answer seems to be to override the super class's designated initializer. http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_6.html

Re: Initialize a subclass object with a base class object

2008-05-19 Thread stephen joseph butler
On Mon, May 19, 2008 at 5:52 PM, Erik Buck [EMAIL PROTECTED] wrote: I am not sure I understand the OP's question, but the shortest answer seems to be to override the super class's designated initializer. I think he wants an Objective-C equivalent to a C++ copy constructor. That is...

Re: Initialize a subclass object with a base class object

2008-05-19 Thread stephen joseph butler
On Mon, May 19, 2008 at 6:00 PM, stephen joseph butler [EMAIL PROTECTED] wrote: ButtonCell *bCell = getFromSomewhere(); MyButtonCell *mCell = new MyButtonCell( bCell ); Ermm... MyButtonCell *mCell = new MyButtonCell( *bCell ); But you knew that :) ___