Re: DataSource protocol
Re: DataSource protocol
- Subject: Re: DataSource protocol
- From: Carlos Weber <email@hidden>
- Date: Sat, 19 Jan 2002 08:17:46 -1000
On Saturday, January 19, 2002, at 04:25 , Marinus van der Lugt wrote:
Hi All,
The objects that I pass on to the NSTableView via the DataSource
protocol seem to be released by the NSTableView. When I try to
access these objects later the app crashes.
Well, after a week of searching I finally found the cause.
The test data objects that I displayed in the TableView were created
with
conveniance constructors. But conveniance constructors autorelease
the objects they create. Thus causing the object's disappearance
after the initial TableView is drawn.
I suspect that this error is quite common in a multitude of forms with
beginning Cocoa programmers.
You are right. The significance of so-called "convenience constructors"
and the fact that they return autoreleased instances didn't sink in with
me until after several months of blundering around. Check out the
Stepwise site's "Cocoa Resources" section for several articles
summarizing the Tao of Cocoa Memory Management.