From: Eloy D. <elo...@gm...> - 2007-08-04 16:05:24
|
Hey Lrz, That would have been very nice! :) However unfortunately NSObject doesn't implement copyWithZone... >> foo = OSX::NSObject.alloc.init => #<OSX::NSObject:0x2e00e class='NSObject' id=0x159ac60> >> foo.objc_methods.grep(/zone/i) => ["zone"] Eloy On 8/4/07, Laurent Sansonetti <lsa...@ap...> wrote: > Try: > > def copyWithZone(zone) > copy = super_copyWithZone(zone) > # set your attributes to copy > # ex: > # copy.title = self.title > return copy > end > > Laurent > > On Aug 4, 2007, at 5:53 PM, Eloy Duran wrote: > > > Hello, > > > > I'm trying to write my own custom NSCell for a tableview. > > However, the table view tries to call #copyWithZone on my objects, > > which are subclasses of NSObject. So I was trying to create a working > > #copyWithZone, but no matter what I do it always crashes immediately. > > For instance I have the following, but it doesn't even write to the > > console: > > > > def copyWithZone(zone) > > puts 'COPY!' > > copy = Download.allocWithZone(zone).init > > self.instance_variables.each do |iv| > > copy.instance_variable_set iv, self.instance_variable_get(iv) > > end > > return copy > > end > > > > Backtrace: > > > > #0 0x90a594c0 in objc_msgSend () > > #1 0xbfffc21c in ?? () > > #2 0x0002b850 in ocid_to_rbobj () > > #3 0x0002df10 in ocdata_to_rbobj () > > #4 0x0003051a in ovmix_register_ruby_method () > > #5 0x00031a98 in rbobj_call_ruby () > > #6 0x00031075 in ovmix_register_ruby_method () > > #7 0x0002f8b9 in init_ovmix () > > #8 0x927fa468 in -[NSObject(NSForwardInvocation) forward::] () > > #9 0x90a5ccc1 in _objc_msgForward () > > #10 0x932aed02 in -[NSCell _setContents:] () > > #11 0x932aec95 in -[NSCell setObjectValue:] () > > #12 0x9353abaa in -[_NSPlaceholderTextFieldPlugin > > showValue:inObject:] () > > #13 0x93511593 in -[NSValueBinder showValue:inObject:] () > > #14 0x93510938 in -[NSValueBinder > > _adjustObject:mode:observedController:observedKeyPath:context:editableState:adjustState > > :] > > () > > #15 0x9353a287 in -[NSValueBinder > > updateTableColumnDataCell:forDisplayAtIndex:] () > > #16 0x9353a9ef in -[NSTextValueBinder > > updateTableColumnDataCell:forDisplayAtIndex:] () > > #17 0x9353a1d6 in -[_NSBindingAdaptor > > tableColumn:willDisplayCell:row:] () > > #18 0x93402a9d in -[NSTableView > > _sendDelegateWillDisplayCell:forColumn:row:] () > > #19 0x933ea065 in -[NSTableView _drawContentsAtRow:column:clipRect:] > > () > > #20 0x933e902b in -[NSTableView drawRow:clipRect:] () > > #21 0x933e67ce in -[NSTableView drawRowIndexes:clipRect:] () > > #22 0x933e56a4 in -[NSTableView drawRect:] () > > #23 0x933113b1 in -[NSView _drawRect:clip:] () > > #24 0x9331040b in -[NSView > > _recursiveDisplayAllDirtyWithLockFocus:visRect:] () > > #25 0x9330f473 in -[NSView > > _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView > > :] > > () > > #26 0x93310041 in -[NSView > > _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView > > :] > > () > > #27 0x93310041 in -[NSView > > _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView > > :] > > () > > #28 0x93310041 in -[NSView > > _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView > > :] > > () > > #29 0x93310041 in -[NSView > > _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView > > :] > > () > > #30 0x9330eb78 in -[NSThemeFrame > > _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView > > :] > > () > > #31 0x9330e362 in -[NSView > > _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] > > () > > #32 0x9330dc8e in -[NSView displayIfNeeded] () > > #33 0x9330da32 in -[NSWindow displayIfNeeded] () > > #34 0x9335dd6c in _handleWindowNeedsDisplay () > > #35 0x9082dd6e in __CFRunLoopDoObservers () > > #36 0x9082ce10 in CFRunLoopRunSpecific () > > #37 0x9082cace in CFRunLoopRunInMode () > > #38 0x92dec8d8 in RunCurrentEventLoopInMode () > > #39 0x92debfe2 in ReceiveNextEventCommon () > > #40 0x92debe39 in BlockUntilNextEventMatchingListInMode () > > #41 0x93292465 in _DPSNextEvent () > > #42 0x93292056 in -[NSApplication > > nextEventMatchingMask:untilDate:inMode:dequeue:] () > > #43 0x9328bddb in -[NSApplication run] () > > #44 0x9327fd2f in NSApplicationMain () > > #45 0x0003fc0d in ffi_call_SYSV () > > #46 0x0003fbae in ffi_call () > > #47 0x0003cfa0 in rb_ffi_dispatch () > > #48 0x00035ca0 in find_bs_boxed_by_encoding () > > #49 0x00221e09 in call_cfunc () > > #50 0x002214f2 in rb_call0 () > > #51 0x00222489 in rb_call () > > #52 0x0021c34a in rb_eval () > > #53 0x00217d9c in eval_node () > > #54 0x00218369 in ruby_exec_internal () > > #55 0x002183b3 in ruby_exec () > > #56 0x002183dd in ruby_run () > > #57 0x00033474 in RBApplicationMain () > > #58 0x00002886 in main () > > > > So does somebody know of a good way of implementing this with > > RubyCocoa? > > > > Cheers, > > Eloy > > > > PS: I'm on svn rev 1983 > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a > > browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > Rubycocoa-talk mailing list > > Rub...@li... > > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > |