• 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
Trying to understand -- please help...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trying to understand -- please help...


  • Subject: Trying to understand -- please help...
  • From: Peter Hudson <email@hidden>
  • Date: Wed, 21 May 2008 17:47:38 +0100

The line of code [NSArray arrayWithObjects: c0, ...c9, nil]; produces
an array all right - but as you have used a class initializer, it will auto release
when you return from the method where it was created.
Any initialiser with a "+" in front of it returns an autoreleased object
- hence you MUST retain them or else they are simply released
when the autorelease pool they are created in is released - which you can treat
as occurring at the end of the method in which the init occurs.


Do it like this    [ [NSArray arrayWithObjects: c0, ...c9, nil] retain];

and then it will stay around until you send it a release message,
probably  in the dealloc method;

		[cityArray  release];

(PH)
_______________________________________________

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: Trying to understand -- please help...
      • From: Uli Kusterer <email@hidden>
    • Re: Trying to understand -- please help...
      • From: "I. Savant" <email@hidden>
    • Re: Trying to understand -- please help...
      • From: "Sherm Pendley" <email@hidden>
    • Re: Trying to understand -- please help...
      • From: "Shawn Erickson" <email@hidden>
  • Prev by Date: Re: Writing Cocoa framework's for iPhone
  • Next by Date: [Moderator] [close this thread please] Re: Writing Cocoa framework's for iPhone
  • Previous by thread: Re: Trying to understand -- please help...
  • Next by thread: Re: Trying to understand -- please help...
  • Index(es):
    • Date
    • Thread