• 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: What classes have -init?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What classes have -init?


  • Subject: Re: What classes have -init?
  • From: Gordon Apple <email@hidden>
  • Date: Thu, 11 Feb 2010 11:03:44 -0600
  • Thread-topic: What classes have -init?

It's unfortunate that all initializers don't at least call "init"
internally.  That would make subclassing easier if all one needs is to set a
few ivars.  In the earlier days of MacApp (Pascal and first C++ versions)
there was a basic initializer, similar to "init", called by all classes,
just for that purpose.  Of course, Objective C at least sets them all to
zero, reducing the need -- but it still would have been useful, sometimes
eliminating the need to override multiple initializers.

Of course, you can always override "init" first, just to test whether it
gets called.  But then, there's no guarantee in future versions.

>
> True.
>
> But most classes have designated initializers that configure the class
> properly. They should be documented, although typically they‚re used for
> subclassing the class.
>
>
> On Feb 10, 2010, at 3:49 PM, Henry McGilton (Boulevardier) wrote:
>
>>
>> On Feb 10, 2010, at 12:23 PM, James Walker wrote:
>>
>>> I think at times I've written things like [[NSMutableArray alloc] init] with
>>> no apparent ill effects, but now I notice that the docs for NSMutableArray
>>> and NSArray don't say that there is an init method.  The NSObject docs say
>>> that an init method might raise an exception.  Is there some other init rule
>>> that I've missed, or have I just gotten lucky?
>>
>> When in doubt, remember to look at the super-class documentation:
>>
>> http://developer.apple.com/mac/library/documentation/cocoa/reference/Foundati
>> on/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/doc/uid/200000
>> 50-init
>>
>> All classes that inherit from NSObject (which means pretty much
>> all of them) inherit NSObject's   ˆinit   method, and that's assumed
>> or implicit in the Array examples you referenced above . . .
>>
>
>



_______________________________________________

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: What classes have -init?
      • From: Greg Parker <email@hidden>
    • Re: What classes have -init?
      • From: Scott Ribe <email@hidden>
  • Prev by Date: Re: Copying CLHeading objects does not appear to work . . .
  • Next by Date: Re: iPhone and OS X apps question
  • Previous by thread: Re: What classes have -init?
  • Next by thread: Re: What classes have -init?
  • Index(es):
    • Date
    • Thread