working through the "travel advisor" sample

  • in apple's "Learning Objective-C" book. The part about deleting an item
    from the list is left as an exsercise for the reader (me).

    I assume I have to first figure out which row is currently selected
    (which I've done). I assume that then I need the contents of the cell
    so I know which key to use to delete the item from the dictionary.

    I can't find a way to do this with the NSTableView class.

    I know I'm missing something basic here, can someone point me in the
    right direction?
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • It's deceivingly simple ;)  Just delete the record from your data
    source and send the table a reloadData message.

    I assume your data source is probably just an NSMutableArray (I don't
    have the book handy) ?  If so, just [array removeObjectAtIndex:row];

    -mark

    On Jul 15, 2004, at 11:09 AM, John Spicer wrote:

    > in apple's "Learning Objective-C" book. The part about deleting an
    > item from the list is left as an exsercise for the reader (me).
    >
    > I assume I have to first figure out which row is currently selected
    > (which I've done). I assume that then I need the contents of the cell
    > so I know which key to use to delete the item from the dictionary.
    >
    > I can't find a way to do this with the NSTableView class.
    >
    > I know I'm missing something basic here, can someone point me in the
    > right direction?
    > _______________________________________________
    > cocoa-dev mailing list | <cocoa-dev...>
    > Help/Unsubscribe/Archives:
    > http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    > Do not post admin requests to the list. They will be ignored.
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • It is possible to get the country name from the table, but there's an
    easier way. The rows in the table correspond to the entries in the
    countryKeys array. Use the index you came up with to get countryName
    from countryKeys, then use countryName to delete the proper record from
    countryDict. Don't forget to delete the entry from countryKeys too,
    after you've gotten the name.

    Andrew Wilson

    On Jul 15, 2004, at 2:31 PM, <cocoa-dev-request...> wrote:

    >
    > Message: 7
    > To: <cocoa-dev...>
    > From: John Spicer <johnspicer...>
    > Subject: working through the "travel advisor" sample
    > Date: Thu, 15 Jul 2004 11:09:35 -0500
    >
    > in apple's "Learning Objective-C" book. The part about deleting an item
    > from the list is left as an exsercise for the reader (me).
    >
    > I assume I have to first figure out which row is currently selected
    > (which I've done). I assume that then I need the contents of the cell
    > so I know which key to use to delete the item from the dictionary.
    >
    > I can't find a way to do this with the NSTableView class.
    >
    > I know I'm missing something basic here, can someone point me in the
    > right direction?
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.