From: Chris M. <ch...@oc...> - 2006-12-28 19:24:48
|
Hi Laurent On 28 Dec 2006, at 17:17, Laurent Sansonetti wrote: > Hi Chris, > > On Dec 28, 2006, at 2:11 PM, Chris McGrath wrote: > >> Hi, I'm having a problem with expanding items in a NSOutlineView. The >> toplevel items appear fine, but nearly every time I go to expand them >> I get a crash. It does occasionally work, which seems strange to me. >> > <snipped stuff> > At a glance it looks like your problem is that you return pure-Ruby > items (i.e. they do not inherit from NSObject) to NSOutlineView. So > RubyCocoa has to create proxies for them that are collected at some > time (for some reason), and NSOutlineView expects you to always return > the same object (which is a well known problem also in the Objective-C > world). > > Changing your TestData definition like this should fix the problem. > > <snipped code> Yep, that worked, thanks Laurent. Unfortunately in my real app, the TestData objects are actually ActiveRecord objects, so I can't make them inherit from NSObject. I guess I'll either need to implement my own NSObject derived proxy for the AR objects for display, or look at just using CoreData. My app became a bit of a frankenapp with all the rails stuff I needed to include to get AR "working" anyway so CoreData is probably a saner bet. It looks like the ActiveSupport reloading stuff and RubyCocoa don't play well together. I could get different errors just by changing which was included first until I figured out how to hack the AR side enough to make some progress. I think i'll try with my own proxy objects this evening anyway, just to see how far I can get. Thanks again, Chris |