I think this is not the appropriate forum. Nevertheless, I try to get an answer!
For error recovery in a COCOA program I defined my user dictionary as follows:
id userInfoDict = @{
NSLocalizedDescriptionKey : @"Fehler!",
NSRecoveryAttempterErrorKey : self,
NSLocalizedRecoverySuggestionErrorKey : description,
NSLocalizedRecoveryOptionsErrorKey : @[@"zurücksetzen", @"korrigieren"]
};
The resulting error message contains the localized description as well as the RecoverySuggestion.
But instead of the requested recovery options buttons I get the (system) buttons 'ok' and 'discard changes'.
And 'attemptRecoveryFromError: ……' is not called.
Can somebody give me a hint what my mistakge might be?
Hans
The good news is that I can get and run your project just fine.
The bad news is that it doesn't attempt recovery, and AFAICT this is intentional. It looks to me like the binding validation mechanism suppresses the recovery attempt. (It may be that at the time validateKey is called, the array controller is not in a state where it can fully hand control over to the recovery attempter, but that's just a guess.)
The bindings validation does call "presentError:modalForWindow:…" as expected, but the call is wrapped in a private method that handles this kind of "discard changes?" alert specially. If I just invoke "presentError:" directly, for example when a new path is added, the recovery options are presented correctly.
My suggestions:
— Use a TSI (tech support incident) to get input from Apple as to whether there's any way around the current behavior, but you should expect "no" as a possible answer.
— Alternatively, don't use the validate<key> mechanism at all. It's actually kind of awful as a UI, because it means you can't tab out of the field temporarily, and fix the error later. This is likely to make users angry.
Instead, allow the user to enter incorrect values, and validate them "later" (that is, just before you need to rely on them being correct). You might then invoke "presentError:…" yourself, and the recovery attempter will get control, if that's what you want.
Sorry for the bad news. I don't think you're doing anything wrong, and I think you are right to expect it to attempt recovery, but … it is what it is. Bug report or TSI, if you want to pursue this.