Created
May 6, 2011 08:58
-
-
Save kyleslattery/958658 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Sensible Table View/SCTableViewCell.m b/Sensible Table View/SCTableViewCell.m | |
index a828c53..b1c35d2 100644 | |
--- a/Sensible Table View/SCTableViewCell.m | |
+++ b/Sensible Table View/SCTableViewCell.m | |
@@ -1856,8 +1856,17 @@ | |
{ | |
if([numericValue intValue]==0 && self.displayZeroAsBlank) | |
self.textField.text = nil; | |
- else | |
- self.textField.text = [NSString stringWithFormat:@"%@", numericValue]; | |
+ else { | |
+ NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init]; | |
+ [numFormatter setMinimum:self.minimumValue]; | |
+ [numFormatter setMaximum:self.maximumValue]; | |
+ [numFormatter setAllowsFloats:self.allowFloatValue]; | |
+ [numFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; | |
+ | |
+ self.textField.text = [numFormatter stringFromNumber:numericValue]; | |
+ | |
+ [numFormatter release]; | |
+ } | |
} | |
else | |
{ | |
@@ -1876,8 +1885,15 @@ | |
[super commitChanges]; | |
- if([self.textField.text length]) | |
- self.boundValue = [NSNumber numberWithDouble:[self.textField.text doubleValue]]; | |
+ if([self.textField.text length]) { | |
+ NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init]; | |
+ [numFormatter setMinimum:self.minimumValue]; | |
+ [numFormatter setMaximum:self.maximumValue]; | |
+ [numFormatter setAllowsFloats:self.allowFloatValue]; | |
+ | |
+ self.boundValue = [numFormatter numberFromString:self.textField.text]; | |
+ [numFormatter release]; | |
+ } | |
else | |
self.boundValue = nil; | |
needsCommit = FALSE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment