Re: NSNumberFormattter not working
Re: NSNumberFormattter not working
- Subject: Re: NSNumberFormattter not working
- From: Erik Buck <email@hidden>
- Date: Thu, 12 Jul 2007 12:59:10 -0700 (PDT)
I think that all you need to do is implement an NSFormatter subclass with the following method and no more: (typed in mail)
- (BOOL) isPartialStringValid:(NSString *) partialString
newEditingString:(NSString **) newString
errorDescription:(NSString **) error
{
NSLog(@"entered KIntegerFormatter:isPartialStringValid");
NSAssert(NULL != newString, @"Invalid newString argument");
NSRange validRange = [(*newString) rangeOfCharacterFromSet:[NSCharacterSet decimalDigitCharacterSet]];
*newString = [(*newString)substringWithRange:validRange];
return YES;
}
Then use this formatter anywhere you want only decimal digits entered. Leading zeros are fine.
_______________________________________________
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