• 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 init declaration class needs?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: What init declaration class needs?
      • From: Sherm Pendley <email@hidden>
References: 
 >What init declaration class needs? (From: Roberto Sobachi <email@hidden>)

  • Prev by Date: Re: DictionaryWithContentsOfURL
  • Next by Date: Re: What init declaration class needs?
  • Previous by thread: Re: What init declaration class needs?
  • Next by thread: Re: What init declaration class needs?
  • Index(es):
    • Date
    • Thread