• 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: NSArray- help!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray- help!


  • Subject: Re: NSArray- help!
  • From: j o a r <email@hidden>
  • Date: Sat, 2 Nov 2002 17:50:17 +0100

You are using a convenience method to construct the array, the "arrayWithObjects:" method. This method returns an autoreleased array, meaning that it will be deallocated automatically if you don't explicitly retain it.

On Saturday, Nov 2, 2002, at 17:37 Europe/Stockholm, Dave Sopchak wrote:

-(id) init
{
GuideStar* guideStar1 = [[GuideStar alloc] init];
GuideStar* guideStar2 = [[GuideStar alloc] init];
GuideStar* guideStar3 = [[GuideStar alloc] init];

GuideStar* test;

if (self = [super init])
{
guideStarArray = [NSArray arrayWithObjects: guideStar1, guideStar2, guideStar3, nil];
[guideStar1 release];
[guideStar2 release];
[guideStar3 release];
}
}

This should work better:

- (id) init
{
self = [super init];

if (self != nil)
{
GuideStar* guideStar1 = [[GuideStar alloc] init];
GuideStar* guideStar2 = [[GuideStar alloc] init];
GuideStar* guideStar3 = [[GuideStar alloc] init];

guideStarArray = [[NSArray alloc] initWithObjects: guideStar1, guideStar2, guideStar3, nil];

[guideStar1 release];
[guideStar2 release];
[guideStar3 release];
}

return self;
}
_______________________________________________
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: NSArray- help!
      • From: Dave Sopchak <email@hidden>
References: 
 >NSArray- help! (From: Dave Sopchak <email@hidden>)

  • Prev by Date: NSArray- help!
  • Next by Date: Re: NSArray- help!
  • Previous by thread: NSArray- help!
  • Next by thread: Re: NSArray- help!
  • Index(es):
    • Date
    • Thread