forked from coo-ona/cooViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNSNumberFormatter_Adding.m
56 lines (51 loc) · 1.72 KB
/
NSNumberFormatter_Adding.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// NSNumberFormatter_Adding.m
// cooViewer
//
// Created by coo on 08/01/20.
// Copyright 2008 coo. All rights reserved.
//
#import "NSNumberFormatter_Adding.h"
@implementation NSNumberFormatter (Adding)
- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error
{
NSCharacterSet *nonDigits = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789."] invertedSet];
if ([partialString rangeOfCharacterFromSet:nonDigits].location != NSNotFound){
*error = @"Input is not an integer";
return (NO);
} else {
*error = nil;
return (YES);
}
}
/*
- (BOOL) isPartialStringValid: (NSString **) partialStringPtr
proposedSelectedRange: (NSRangePointer) proposedSelRangePtr
originalString: (NSString *) origString
originalSelectedRange: (NSRange) origSelRange
errorDescription: (NSString **) error
{
NSCharacterSet *nonDigits = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789."] invertedSet];
if ([*partialStringPtr rangeOfCharacterFromSet:nonDigits].location != NSNotFound){
*error = @"Input is not an integer";
return (NO);
} else {
*error = nil;
return (YES);
}
} */
/*
- (BOOL)isPartialStringValid:(NSString **)partialStringPtr
proposedSelectedRange:(NSRangePointer)proposedSelRangePtr
originalString:(NSString *)origString
originalSelectedRange:(NSRange)origSelRange
errorDescription:(NSString **)error
{
[super isPartialStringValid:&partialStringPtr
proposedSelectedRange:proposedSelRangePtr
originalString:origString
originalSelectedRange:origSelRange
errorDescription:&error
];
}*/
@end