What's the right way to validate fields in an editable detail view in a navigation stack? It seems that the API doesn't really provide a good means to do so without a lot of contortions, and so I wonder what the intended behavior is.
Here's what I've got: A UINavigationController stack with a UITableView that shows a list of Jobs. You can add a new job, or select an existing job, and it pushes a new UITableViewController that is a detail view of the Job. Some of the fields in this detail view are editable (i.e. "Name"). I don't want to allow the user to specify an empty name. So I had a separate "Save" button in the top-right of the nav bar, and I would validate everything in there before actually saving the changes to Core Data. I also had to subclass UINavigationController to prompt the user to discard changes if they tapped the back button (I also had to do this if they did something else to dismiss the UIPopover all this lives in). For other reasons, I'd like to change this behavior a bit to avoid the save step all together, and to always save any change. But I still need to validate that they don't try to save an empty name. I'm trying to do this with -[UITextFieldDelegate textFieldShouldEndEditing:], in which I present an alert and return NO if the field is empty. But that doesn't work if they tap the "back" button. In this case, I'm content with simply undoing whatever change they made and not saving the changes without prompting, but I have to be able to detect that that's what's happening. There is no UINavigationControllerDelegate method for popping a view controller, only showing a new one. I guess I could set a flag in -viewWillDisappear: indicating that the field is ending editing because the view is going away, and save or discard (without an alert) in that case. What are your thoughts? -- Rick
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com