• 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: Subclassing NSButton
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclassing NSButton


  • Subject: Re: Subclassing NSButton
  • From: Ryan Stevens <email@hidden>
  • Date: Fri, 4 Nov 2005 17:41:26 -0800


On Nov 4, 2005, at 3:39 PM, Ricky Sharp wrote:


On Nov 4, 2005, at 5:01 PM, Ryan Stevens wrote:


How it's instantiated shouldn't matter, should it? Assuming it's really a subclass of NSButton (and not NSObject or something) initWithCoder should be there.

I'd be most interested in the header.


Depending upon how it's created, different APIs will be called. When programatically creating a view, you typically call initWithFrame: (or a designated initializer that in turn calls intiWithFrame:)


When your view is stored in a nib, it is re-created via initWithCoder.


Of course different methods will be called but that's not what I was saying/asking/whatever...


initWithCoder should be implemented by NSButton (or one of its supers) so that you don't *have* to implement it in your subclass. Create a dummy NSButton subclass without initWithCoder and set the custom class of a button to your subclass in IB....no crash.


Something else that may be going on is due to what cell is being created. When subclassing controls, you typically subclass both the control class and the corresponding cell class. A subclass of NSButton that doesn't implement +cellClass (or any of the other APIs to set the cell class) will use instances of NSButtonCell as its cell.



What would this have to do with the lack of initWithCoder in his subclass of NSButton? Like I said, if it really is a subclass of NSButton initWithCoder is already implemented and there should be no exception.


Maybe the subclass should implement initWithCoder and just call super's implementation. Does it still crash? If so, it's likely not a subclass of NSButton but a subclass of NSObject (which is the default and easily over-looked).
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >Subclassing NSButton (From: Simon BrĂ©e <email@hidden>)
 >Re: Subclassing NSButton (From: Ricky Sharp <email@hidden>)
 >Re: Subclassing NSButton (From: Ryan Stevens <email@hidden>)
 >Re: Subclassing NSButton (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Re: Ad-hoc Core Data queries ?
  • Next by Date: NSTableView Examples
  • Previous by thread: Re: Subclassing NSButton
  • Next by thread: Fwd: DO and threads [SOLUTION]
  • Index(es):
    • Date
    • Thread