• 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: Subclassed control in IB uses original cell class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclassed control in IB uses original cell class


  • Subject: Re: Subclassed control in IB uses original cell class
  • From: "Ken Ferry" <email@hidden>
  • Date: Tue, 11 Dec 2007 15:32:41 -0800

> The problem is that the control ends up with a NSSliderCell and not a
> SMDoubleSliderCell - guess +cellClass does not get invoked for
> archived objects.

Yeah - here's how to think of it.

+cellClass is used when a control needs to instantiate a cell for
itself and it doesn't already have one.

With a nib, both the control and the cell are instantiated in
interface builder, then archived.  -[NSControl initWithCoder:] has
code that looks more or less like this:

	_cell = [[coder decodeObjectForKey:@"NSCell"] retain];

So +cellClass might be called inside of Interface Builder, but it will
not be at runtime in your app.  Unless you write an IB plugin, your
implementation of +cellClass will not be present in IB.

There's a solution, though: In IB3, select the cell in IB and set its
class to your custom subclass, the same as you would do for any other
object in a nib.  Exposing cells as first class objects is a major new
IB feature.

-Ken

On 11/28/07, David Hoerl <email@hidden> wrote:
> I found a neat double knobbed slider on the web:
> http://developer.snowmintcs.com/controls/smdoubleslider/
>
> There is only a IB2 palette, so I figured I'd just add a NSSlider
> object to my NIB, change its class to SMDoubleClass, then do anything
> further in awakeFromNib.
>
> The problem is that the control ends up with a NSSliderCell and not a
> SMDoubleSliderCell - guess +cellClass does not get invoked for
> archived objects.
>
> At first, I could not subclass the cell as a nib2.x file does not
> support it. However, the IB3 docs say I can use the nib3.x file on
> Tiger (for building only, not editing). So, I changed formats,
> changed the cell class, and now all is working as expected.
>
> I was wondering though - suppose I had to stay with IB2 - how would I
> get the correct class of cell?
>
> David
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Programmatically setting a binding with an NSValueTransformer
  • Next by Date: Notification of the end of implicit animations
  • Previous by thread: Parsing XML with NSXMLParser
  • Next by thread: Notification of the end of implicit animations
  • Index(es):
    • Date
    • Thread