handling errors from NSNumberFormatter - how to determine exact nature of the error?
handling errors from NSNumberFormatter - how to determine exact nature of the error?
- Subject: handling errors from NSNumberFormatter - how to determine exact nature of the error?
- From: Rua Haszard Morris <email@hidden>
- Date: Mon, 11 Aug 2008 15:01:39 +1200
I'm using a NSNumberFormatters in a modal dialog to validate text
fields. I want to give the user a specific and appropriate error
message if they try to OK the dialog with an invalid number in a
field. For example I want different error messages for "no string
entered", "non numeric string entered", "value larger than max",
"value less than min".
In my implementation of
control:didFailToFormatString:errorDescription: I get notified that a
format failed, but the description is always "Formatting error". I
tried calling getObjectValue:forString:range:error: on the formatter,
but as far as I can tell the NSError returned is the same for each
error condition.
So.. I could check the passed in string myself, for length, validity,
then max/min, and generate my error message accordingly, but then I'm
reimplementing the validation?
Is there a better way to achieve this?
thanks
Rua HM.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden