• 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: Custom control class question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom control class question


  • Subject: Re: Custom control class question
  • From: Shaun Wexler <email@hidden>
  • Date: Thu, 12 Feb 2004 03:57:39 -0800

On Feb 11, 2004, at 7:24 PM, Jim O'Connor wrote:

I need a custom slider class to be invoked by a nib, so I worked my way down
in the IB classes tab to the NSSlider class and added a subclass,
FavoriteSlider.

Then in my header file is have:

@interface FavoriteSlider : NSSlider
@end

@interface FavoriteSliderCell : NSSliderCell
@end

In my .mm file I have:

@implementation FavoriteSlider
+ (Class) cellClass
{
return [FavoriteSliderClass class];
}
@end

return [FavoriteSliderCell class];

@implementation FavoriteSliderCell
- (void)drawBarInside:(NSRect)aRect flipped:(BOOL)flipped
{
// do some stuff
}
@end

My nib is loaded and the cellClass method is never called.

Am I missing something? I've been away from cocoa for a while, and I wasn't
that proficient at it when I was using it more frequently.

Interface Builder stores an archived copy (of the actual instance you see when creating your layouts) into the nib file, thus archiving the default cell along with it. There are a few ways to handle this, but the easiest (apart from fixing the above error in your code) would be to tweak your FavoriteSlider class to replace the cell with the proper cellClass upon instantiation.

In FavoriteSlider -initWithCoder:, first call super's implementation, then if ![cell isKindOfClass:[FavoriteSliderCell class]], create a new cell using the archived properties of the instance's cell, and then [self setCell:favoriteCell];
--
Shaun Wexler
MacFOH
http://www.macfoh.com
_______________________________________________
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: Custom control class question
      • From: "Jim O'Connor" <email@hidden>
References: 
 >Custom control class question (From: "Jim O'Connor" <email@hidden>)

  • Prev by Date: performSelectorOnMainThread and other thread notifications
  • Next by Date: Fwd: (Solved) prefs stopped saving.
  • Previous by thread: Custom control class question
  • Next by thread: Re: Custom control class question
  • Index(es):
    • Date
    • Thread