Re: runtime error with NSArray no more!
Re: runtime error with NSArray no more!
- Subject: Re: runtime error with NSArray no more!
- From: Sherm Pendley <email@hidden>
- Date: Fri, 6 Dec 2002 10:18:05 -0500
On Friday, December 6, 2002, at 02:47 AM, Mike McCune wrote:
But it never seems to find the first checked box. I've got these 6
check boxes in the NSArray that I just got working. well lemme know if
that makes any sense.
Is that the array you created with arrayWithObjects:? If so, that method
returns an autoreleased object. An autoreleased object normally only
exists for the lifetime of the event (in this case, the awakeFromNib:
event) in which it was created.
To create an array that persists for a longer time, you need to use
[[NSArray alloc] initWithObjects: ] or [[NSMutableArray alloc]
initWithObjects: ] to obtain an object that has been retained, or send a
retain message to one that has been obtained with the arrayWithObjects:
method.
If you create an object with init: or copy: method, or retain it by
sending it a retain message, you are establishing "ownership" over that
object, and are responsible for also releasing it by sending it a
release message when you're finished using it.
For more about memory management in Objective-C, see:
<URL:
file:///Developer/Documentation/Cocoa/TasksAndConcepts/ProgrammingTopics/MemoryMgmt/
index.html>
sherm--
If you listen to a UNIX shell, can you hear the C?
_______________________________________________
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.