From: Steven D. A. <st...@ne...> - 2009-01-31 07:39:09
|
Hey Brian, what you are reading is the place where Hillegass attempt to describe how to implement undo for edits. For example, if I type in "When in the course of human events" in a text field, if I hit undo, that text should be removed. The kind of undoing that I implemented is the kind that goes right up to page 145, which is where I got stuck. In that undo, we merely manage the @employees array, that is, remove the most recent addition if undo is selected. For that kind of undoing, startObservingObject is not required. Alli's very helpful suggestion was to look at the kvc_array_accessor method as a way to inform RubyCocoa that we are employing key-value bonding on a particular element. This is not necessary in ObjC, therefore Hillegass didn't discuss it. Note that Brian Marick's book, RubyCocoa, which is still in beta on the Pragmatic Programmer's website, does discuss the issue to some degree. steven On Jan 28, 2009, at 6:45 PM, Brian Marick wrote: > I'm confused by the Objective-C version. It doesn't have the > MyDocument.m method startObservingPerson (on p. 146 of Hillegass). It > shouldn't work without setting up observing. (I can't check - won't > build in my older version of Xcode.) > > Am I looking at the wrong pages? > > On Jan 26, 2009, at 1:24 PM, Steven D. Arnold wrote: > >> Following up on my previous post related to the "raiseman" >> application covered in Aaron Hillegass's Cocoa Programming for Mac >> OS X..... I implemented the same program in Objective-C, an >> identical analogue to the program in Ruby, and it works fine in >> Objective-C. That is, the expected methods to insert and remove >> "employee" objects (see below) are called in Obj-C but not >> RubyCocoa. That tells me there is a bug in the RubyCocoa interface >> that prevents key-value coding from working properly.....or possibly >> I am missing some detail in my implementation of the RubyCocoa >> program. The Objective-C project which works fine is attached. Run >> the program, and then add several records and undo them by typing >> command-Z (or selecting undo from the Edit menu). If you do this, >> the key-value coding will work fine, that is, the following methods >> will be called to undo and redo: >> >> - (void)insertObject:(Person *)p inEmployeesAtIndex:(int)idx >> - (void)removeObjectFromEmployeesAtIndex:(int)idx >> >> The equivalent methods in the Ruby implementation are not called: >> >> def insertObject_inEmployeesAtIndex(p, index) >> def removeObjectFromEmployeesAtIndex(index) >> >> I have also tried these Ruby methods with a trailing _ just to be >> sure that's not the problem. It didn't change the result. >> >> steven >> >> >> <raiseman-objc.zip> >> >> >> >> >> On Jan 24, 2009, at 11:33 PM, Steven Arnold wrote: >> >>> Hello, I am working through the book Cocoa Programming for Mac OS X >>> by Aaron Hillegass using RubyCocoa rather than Objective-C, and I >>> am at the section where we are attempting to implement undo for the >>> add new employee and delete new employee buttons. >>> >>> My controller object as an @employees array as a member value. >>> Given this name, I have implemented, in my controller, the >>> functions: >>> >>> insertObject_inEmployeesAtIndex(p, idx), and >>> removeObjctFromEmployeesAtIndex(idx) >>> >>> According to the book, "[...] these methods will be called >>> automatically when the NSArrayController wishes ro insert or remove >>> messages." However, my functions do not seem to be getting >>> called. I have put NSLog statements to see whether they are being >>> called, but right now it appears not. >>> >>> My project is packaged below. If you have any idea what I might be >>> doing wrong, please let me know! >>> >>> eteven >>> >>> >>> <raiseman.zip> >>> ------------------------------------------------------------------------------ >>> This SF.net email is sponsored by: >>> SourcForge Community >>> SourceForge wants to tell your story. >>> http://p.sf.net/sfu/sf-spreadtheword_______________________________________________ >>> Rubycocoa-talk mailing list >>> Rub...@li... >>> https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by: >> SourcForge Community >> SourceForge wants to tell your story. >> http://p.sf.net/sfu/sf-spreadtheword_______________________________________________ >> Rubycocoa-talk mailing list >> Rub...@li... >> https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > > > > ----- > Brian Marick, independent consultant > Mostly on agile methods with a testing slant > www.exampler.com, www.exampler.com/blog, www.twitter.com/marick > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > |