• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Copy constructing to a subclass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copy constructing to a subclass


  • Subject: Re: Copy constructing to a subclass
  • From: Nicholas Francis <email@hidden>
  • Date: Wed, 7 Jan 2004 23:33:38 +0100

Basically, I'm making a framework that makes Aqua look like the apple pro apps - hence, I want to replace all NSButtonCells with my own derived OTEButtonCell (repeat ad nauseum for other cell classes)

I can use [NSButton setCellClass: OTEButtonClass] to do a replace, but that only works for controls created from code (of which I have many ;-)

I would like to do the replacement of stuff I load from nibs...

1) use [OTEButtonCell poseAsClass: [NSButtonCell class]] - this works across the app - However, I want to preserve some nibs as old-style aqua apps (e.g. preference pane). This means doing:
2) replace the cell either when loading from the nib or immediately afterwards (Im not sure about this ;-) - this is where I need to construct the subclass from the superclass.

Nicholas Francis

On Jan 7, 2004, at 11:08 PM, Alexander Spohr wrote:

any tip on _why_ you try to do that?

atze


Am 07.01.2004 um 21:27 schrieb Nicholas Francis:

Hi guys...

I want to copy-construct an object to a subclass and am trying to find a smarter way of doing it... Here's how I do at the moment:

@interface OTEButtonCell : NSButtonCell {
// no private variables
}
-(id)initWithNSButtonCell:(NSButtonCell *)src;
@end

@implementation OTEButtonCell
-(id)initWithNSButtonCell:(NSButtonCell *)src {
self = [super init]; // etc...
[self setControlSize: [src controlSize]];
[self setImagePosition: [src ImagePosition]];
// etc...
return self;
}
@end

My question is: is there a way to avoid having to type out all the [self setProperty: [src proprty]]... It gets rather tedius and error-prone...

TIA,
Nicholas
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Copy constructing to a subclass (From: Nicholas Francis <email@hidden>)

  • Prev by Date: Cd ejection detecting
  • Next by Date: Re: Thinking about shareware prices... (was a question about NSDate inside userDefaults)
  • Previous by thread: Copy constructing to a subclass
  • Next by thread: displaying NSUpArrowFunctionKey, NSDeleteFunctionKey and friends?
  • Index(es):
    • Date
    • Thread