• 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
NSTextFieldCell subclass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextFieldCell subclass


  • Subject: NSTextFieldCell subclass
  • From: David Schmitt <email@hidden>
  • Date: Tue, 23 Sep 2003 22:24:37 -0400

Previously I had posted a rather involved problem with my custom NSTextFieldCell being deallocated. Given the complexity of my question, I wasn't surprised that no one answered.

I've tracked the problem down further to what appears to be either a basic problem on my part or a Cocoa bug.

All my test app does now is subclass NSTextFieldCell and override -init and -dealloc to send an NSLog to indicate these methods have been called. It uses a two column table, and sets the datacell of the first column to this subclassed NSTextFieldCell.

The results are that -init is called once, but each and every time I click in the subclassed cell, -dealloc gets called. How (and why) can this be? I've looked at this for days and can't figure it out.

Thanks,
David

--------> Here's the subclass code:

#import <Foundation/Foundation.h>
@interface DASTextFieldCell : NSTextFieldCell {
}
@end

@implementation DASTextFieldCell
-(id)init
{
NSLog(@"Init called for object at: %p", self);
return [super init];
}

-(void)dealloc
{
NSLog(@"Dealloc called for object at: %p",self);
[super dealloc];
}

@end

--------> and here's the code that creates an instance of the subclass and sets it as the dataCell of the 1st tableColumn, and also feeds 10 rows of data to the table.

#import <Foundation/Foundation.h>
#import "DASTextFieldCell.h"

@interface Controller : NSObject {
IBOutlet NSTableView *myTable;
}

@end
@implementation Controller
-(void)awakeFromNib
{

[[[myTable tableColumns] objectAtIndex:0] setDataCell:[[DASTextFieldCell alloc] initTextCell:@"test"]];
}

- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
return 10;
}

- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
return [NSString stringWithString:@"Loooooooong string"];
}

@end
_______________________________________________
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.

  • Follow-Ups:
    • Re: NSTextFieldCell subclass
      • From: "Alastair J.Houghton" <email@hidden>
  • Prev by Date: Re: NSResponder
  • Next by Date: Re: NSMovieView problem
  • Previous by thread: Re: Silly question: Company name
  • Next by thread: Re: NSTextFieldCell subclass
  • Index(es):
    • Date
    • Thread