Re: Overiding NSButton initWithFrame: (doesn't work)
Re: Overiding NSButton initWithFrame: (doesn't work)
- Subject: Re: Overiding NSButton initWithFrame: (doesn't work)
- From: Darrin Filer <email@hidden>
- Date: Sat, 2 Feb 2002 12:39:52 -0500
Now I remember running into the same dilemma before. Its best not to
duplicate code in multiple places yet there is no single init function
which is guaranteed to be called. Some initialization needs to take
place no matter whether the instance was progromatically created or
decoded from a nib. What is the most elegant solution?
Off the top of my head its probably best to call my own universal init
routine from awakeFromNib, initWithFrame, and initWithCoder if I want to
ensure that the same block of code is always used for initialization.Yes?
darrin filer
On Saturday, February 2, 2002, at 01:39 AM, Vince DeMarco wrote:
On Friday, February 1, 2002, at 06:25 PM, Nathan Day wrote:
When un-archiving, ie from a nib, the designated initializer is -
(id)initWithCoder:(NSCoder *)decoder
Yes, but use the awakeFromNib method instead that is what its there for.
vince
On Saturday, February 2, 2002, at 07:10 AM, Darrin Filer wrote:
I've subclassed NSButton but can't get its custom init routine to
fire. The apple docs instruct us to:
"Override the designated initializer (NSView's initWithFrame: method)
if you create a subclass of NSButton that performs its own
initialization."
The buttons draw themselves onto the screen as defined in the nib
file. However, the debugger never reaches the breakpoint on the first
line of the initWithFrame method... Any ideas?
Here's the code from my interface and implementation files.
===============================================
/* DFFooterButton */
#import <Cocoa/Cocoa.h>
@interface DFFooterButton : NSButton
{
NSImage *image;
NSImage *sourceImage;
NSRect leftSourceRect;
NSRect middleSourceRect;
NSRect rightSourceRect;
}
- (void)redrawImage;
- (id)initWithFrame:(NSRect)frameRect;
@end
===============================================
#import "DFFooterButton.h"
@implementation DFFooterButton
- (id)initWithFrame:(NSRect)frameRect
{
BREAKPOINT HERE IS NEVER REACHED
self = [super initWithFrame:frameRect];
if (self)
{
...
===============================================
_______________________________________________
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.
_______________________________________________
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.