unrecognized selector (Hillegass chapter 8 challenge 2)

Discussion in 'Mac Programming' started by John Baughman, Jul 9, 2009.

  1. John Baughman macrumors regular

    Oct 27, 2003
    Can't get challenge 2 to work. I get the following in the console and the application hangs without opening the window...

    2009-07-09 13:48:24.596 RainManManual[29907:813] *** -[_NSControllerObjectProxy copyWithZone:]:
    unrecognized selector sent to instance 0x16c1f0

    Is there more code I need to add to what is listed on pages 136-137? If not I suspect I am not setting things up in IB correctly. This exception hits right after the numberOfRowsInTableView method is called. Which I think is the first time the tableView accesses the method.

    I made a copy of my working RaiseMan and continued with the original
    I did not change anything in person.h
    I added the code found on pages 136-137
    In IB I replaced the ArrayController with a custom object.
    Set the custom object's class to MyDocument
    Set the custom object's outlet to the tableView (drag from controller to the tableView
    Set the data source and delegate of the tableView to the controller (drag from the tableView to the Controler)
    Set the employee and raise column's identifier to personName and expectedRaise in the inspector
    Set the sent actions for the Add Employee and Delete buttons to createEmployee and removeEmployee (drag from buttons to Controller)

    What am I missing or doing wrong?

    Thanks for any help.

  2. mdeh macrumors 6502

    Jan 3, 2009
    So, for whatever reason you are sending a message to an object that is unable to respond to it.

    I did this sans custom object. Just use the delegate methods and datasource as Hillegass did in the earlier chapters. If you really get stuck, contact me privately and I will zip you my attempt.

    ps...John, if you have copied pages 136 and 137, you are **really** close to getting it to work. First, delete that custom object, then make the appropriate connections in IB. Remember, File's owner is myDocument. Page 136 essentially implements the manipulation of your datasource, and page 137 implements the delegate methods needed so that the TableView can interact with it's dataSource.
  3. petron macrumors member

    May 22, 2009
    Malmo, Sweden
    Hi, John.

    I agree with MDEH that you are sending a message to an object that is anable to respond to it.
    I did the challenge, but do not remember the details now. I will look at it when back at home.

    It seems that you either
    : forgot some retain, or have too many releases and released object that you want to use
    : wrong or lack of some bindings
    : wrong keypaths

    Good Luck

  4. John Baughman thread starter macrumors regular

    Oct 27, 2003
    Petron, I think that your observation is probably the culprit here. I really do not have a handle on garbage collection yet.

    For MDEH: Thanks I am going to try it without the custom object. I see on the book's forum that others have done it successfuly with a custom object so I think it can be done. I may revisit it and see if I can tinker with the retains and releases a bit and get it to work with the control object.


  5. zbhagg macrumors newbie

    Dec 13, 2009
    Aaron Hillegass, Chapter 8, Challenge 2

    I ffigured it out!. Should have been more attentive when copying code from
    Hillegass book.

Share This Page