• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
adding rows to an array-controller managed table atomically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

adding rows to an array-controller managed table atomically


  • Subject: adding rows to an array-controller managed table atomically
  • From: "R. Matthew Emerson" <email@hidden>
  • Date: Thu, 9 Feb 2006 20:57:35 -0500

Suppose that there is a Core Data entity called a Point. A Point is simply a pair of floats, x and y. There is no default value for either x or y.

These (x, y) pairs are presented in a table view bound to an array controller. The data are sorted in increasing x order because the the array controller is sent an appropriate setSortDescriptors: message.

A button sends the add: action to the array controller.

With this context in place, the issue is this:

When the add button is clicked, a row is added to the table. After entering a value for x, the row immediately gets sorted into place.

If tab is used to exit the cell being edited, the new row remains selected, but it is necessary to double-click in the y cell to finish entering the data in the row. If return is used to end the editing, the selection doesn't even follow the new row, and it is necessary to look for the new, partially complete row.

When a new row is added, I would like both x and y values to be supplied before the addition is considered complete, and the row is sorted into its place. In other words, addition of a row should be atomic; a "transaction," if you will. Until both fields are filled in, tab and return should move the editing focus to the other cell in the row.

It would seem that the NSTableView delegate method selectionShouldChangeInTableView: might be the place to handle this. I tried this, returning NO if either valueForKey:@"x" or @"y" is nil, and the row stays selected even if the edit is ended by hitting return.

But, I haven't yet thought of a way to get the array controller not to sort the row into place immediately after a value in the x cell is entered.

Would anyone have any hints or suggestions? I think I would rather keep the editing in the table view proper rather than making the user enter the data in a pair of separate text fields.


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: adding rows to an array-controller managed table atomically
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Re: Using zlib for i386 (or Universal) builds on PPC clients
  • Next by Date: AGRegex question
  • Previous by thread: Re: Carbon AudioUnitView in an NSWindow
  • Next by thread: Re: adding rows to an array-controller managed table atomically
  • Index(es):
    • Date
    • Thread