Re: What init declaration class needs?
Re: What init declaration class needs?
- Subject: Re: What init declaration class needs?
- From: Clark Cox <email@hidden>
- Date: Fri, 13 Feb 2004 10:04:31 -0500
On 2004/02/13, at 8:30, Roberto Sobachi wrote:
>
- (listCollection *) init
>
{
>
[super init];
>
list = [[NSMutableArray alloc] init];
>
return self;
>
}
>
>
What does it need?
>
>
If I try to know the count of the Array from another class, I can't, it
>
returns 0, also if I add objects to it.
>
>
Why?
I don't quite understand your question, but there is a possibility that
[super init] is returning nil, for that reason it is usually better to
write -init methods in one of the following forms (the difference is
purely stylistic, but some prefer one over the other):
-(id)init
{
if(self = [super init])
{
list = [[NSMutableArray alloc] init];
}
return self;
}
or
-(id)init
{
self = [super init];
if(self)
{
list = [[NSMutableArray alloc] init];
}
return self;
}
--
Clark S. Cox III
email@hidden
http://homepage.mac.com/clarkcox3/
http://homepage.mac.com/clarkcox3/blog/B1196589870/index.html
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.