What I am trying to do is improve on the "A Sheet for Creating a New Employee" example from the NSPersistentDocument Core Data Tutorial. One feature that I want to add is conditionally enabling the "Create" button only when the new object being edited by the sheet is actually valid for insertion.
The problem is, how do you handle the edge case where the user has typed into the last of the required fields, but Cocoa hasn't committed the edit yet? Here is the code I have thrashed out so far in a Pastebin.
The three (!) hi-lighted lines show where I am calling -validateForInsert: and the comments and code following them shows all the ways this is ugly and inadequate… I would be thrilled to be told I'm on completely the wrong track here and there is a simple solution that has eluded me.