• 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
Best practice for overridden initializers in subclasses
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Best practice for overridden initializers in subclasses


  • Subject: Best practice for overridden initializers in subclasses
  • From: Andy Klepack <email@hidden>
  • Date: Tue, 25 Mar 2008 15:01:26 -0700
  • Acceptlanguage: en-US
  • Thread-topic: Best practice for overridden initializers in subclasses

I have a subclass of NSObject that provides its own designated initializer that allows client code to configure an instance with initial values. Instances of the class itself are immutable. At the same time, instances where no initial values are supplied do not make conceptual sense.

I'm wondering how to deal with overriding the 'init' method of NSObject. There's really no sensible default values that I could have init pass along to my designated initializer. It doesn't make sense for clients to call 'init' and I'm debating whether to return nil, throw some sort of exception, make the instance 'dead' and essentially do nothing, or to do something else..

Anyone have a recommendation for the best practice in this case?
-Andy

_______________________________________________

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

  • Follow-Ups:
    • Re: Best practice for overridden initializers in subclasses
      • From: "Kyle Sluder" <email@hidden>
    • Re: Best practice for overridden initializers in subclasses
      • From: Andy Lee <email@hidden>
    • Re: Best practice for overridden initializers in subclasses
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Source list using bindings?
  • Next by Date: Re: Garbage collection - was Beginner with Cocoa
  • Previous by thread: Re: Disabling NSTableView's text cell wrap-around tool tip?
  • Next by thread: Re: Best practice for overridden initializers in subclasses
  • Index(es):
    • Date
    • Thread