Re: Initializing an Array
Re: Initializing an Array
- Subject: Re: Initializing an Array
- From: Bob Savage <email@hidden>
- Date: Fri, 25 Jan 2002 18:49:36 -0600
Can somebody provide a more precise citation for the problem in the
documentation? I haven't found the problem to which some people are
referring. For example what page in the PDF?
Bob
on 1/24/02 6:57 PM, jgo at email@hidden wrote:
>
> I looked back at my copy of the book and it definitely says
>
> (page 86 in my copy, "NeXT Developer's Library: Object-Oriented
>
> Programming and the Objective-C Language"):
>
>
>
> [super init]
>
>
>
> NOT
>
>
>
> [[super alloc] init]
>
>
>
> If your copy has an error like this, could you please send the Apple
>
> documentation team a bug report with the page number on which the
>
> error occurs.
>
>
I'm getting slightly more confused every time I get to another
>
message in this thread.
>
>
Presumably, before the init is executed, the alloc for self has
>
already done its thing, a la Fred * george = [[Fred alloc] init];
>
where by the time the init happens, Fred has already allocated
>
its memory.
>
>
That's fine as far as it goes. But in the book (PDF), the example
>
is lacking in context (no surprise), and later paragraphs muddy the
>
waters.
>
>
So, where are we? We've allocated self, but we need to do the
>
super init message to set up the ivars that super takes care of.
>
if (...)
>
{
>
[super init];
>
}
if ([super init]) {
// initalize our subclass' ivars
}
return self;
Bob