On 19 Jul 2008, at 23:18, Quincey Morris wrote:

On Jul 19, 2008, at 14:35, Paul Sargent wrote:

This works fine the first time the view is populated, but when it's refreshed it just calls the second method with the pointers to the dictionaries I return first time round. Trouble is they've been autoreleased by now.

I think you mean "deallocated", not "autoreleased". The question is, what's your evidence that they're deallocated? Is something crashing?

Just to be clear, I mean the object was de-allocated due to it being an object created by a convenience method, and the auto release pool it was in was released when control went back to the event loop.

Yes, when the OutlineView redraws for some reason (e.g. a mouse click), it re-accesses the objects I returned last time (nothing wrong with that). Trouble is, they are no longer valid, resulting in a crash or a zombie log message if I have zombies enabled. I was just surprised by the fact the OutlineView held pointers to objects it didn't retain.

The main thing that's wrong here is that you're returning a *different* object from outlineView:child:ofItem: each time. You should return the same object if you are given the same parameters. If finding extraInfo is not incredibly expensive, you could just return aDataItem in the first method, and find extraInfo in the second.

While you're right I would return different objects if I was called twice, I'm not. As I understand it the Outline View will only ask for objects when it knows the data has changed (e.g. after a reloadData or reloadItem call) at which point it needs to expect a different object.

It's exactly the cost that took me down the road of bundling the info up into a dictionary, so any other call backs didn't need to re- evaluate things. Obviously I wasn't expecting anybody to guess that from the code I posted.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to