Trying to understand -- please help...
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