Up
Authors
- Fred Kiefer (
FredKiefer@gmx.de
)
-
- Richard Frith-Macdonald (
rfm@gnu.org
)
-
Version: 31973
Date: 2011-01-29 16:35:22 +0100 (Sat, 29 Jan 2011)
Copyright: (C) 2000 Free Software Foundation, Inc.
- Declared in:
- Foundation/NSNumberFormatter.h
Availability: MacOS-X 10.0.0
This class is currently not implemented in
GNUstep! All set methods will work, but
stringForObject: will ignore the
format completely. The documentation below
describes what the behavior SHOULD be...
A specialization of the
NSFormatter
class for generating string representations of
numbers
NSNumber
and
NSDecimalNumber
instances) and for parsing numeric values in strings.
See the
NSFormatter
documentation for description of the
basic methods for formatting and parsing that
are available.
There are no convenience initializers or
constructors for this class. Instead,
to obtain an instance, call alloc init and then
-setFormat:
.
The basic format of a format string uses "#"
signs to represent digits, and other
characters to represent themselves, in a
context-dependent way. Thus, for
example, @"#,###.00"
means to
print the number ending in.00 if it has no
decimal part, otherwise print two decimal
places, and to print one comma if it is
greater than 1000. Thus, 1000 prints as
"1,000.00", and 1444555.979 prints as
"1444,555.98" (see
-setRoundingBehavior:).
After setting the format, you may change the
thousands separator and decimal point
using set methods, or by calling
-setLocalizesFormat:
.
You may set separate formats to be used for
positive numbers, negative numbers, and
zero independently.
In addition, this class supports attributed
strings (see
NSAttributedString
), so that you can specify font and color attributes, among others, to display aspects of a number. You can assign specific sets of attributes for positive and negative numbers, and for specific cases including 0, NaN, and nil
...
Method summary
+ (void)
setDefaultFormatterBehavior: (
NSNumberFormatterBehavior)behavior;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (BOOL)
allowsFloats;
Availability: MacOS-X 10.0.0
Returns whether number parsing will accept floating
point values or generate an exception (only
int values are valid). Default is
YES
.
- (BOOL)
alwaysShowsDecimalSeparator;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSAttributedString*)
attributedStringForNil;
Availability: MacOS-X 10.0.0
Returns the exact attributed string used for
nil
values. By default this is an empty
string.
- (
NSAttributedString*)
attributedStringForNotANumber;
Availability: MacOS-X 10.0.0
Returns the exact attributed string used for NaN
values. By default this is the string "NaN" with no
attributes.
- (
NSAttributedString*)
attributedStringForZero;
Availability: MacOS-X 10.0.0
Returns the exact attributed string used for zero
values. By default this is based on the format for
zero values, if set, or the format for positive values
otherwise.
- (
NSString*)
currencyCode;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
currencyDecimalSeparator;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
currencyGroupingSeparator;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
currencySymbol;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
decimalSeparator;
Availability: MacOS-X 10.0.0
Returns thousands separator used; default is '.'.
- (
NSString*)
exponentSymbol;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
format;
Availability: MacOS-X 10.0.0
Returns the format string this instance was
initialized with.
- (
NSUInteger)
formatWidth;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (BOOL)
generatesDecimalNubmers;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (BOOL)
getObjectValue: (out id*)anObject
forString: (
NSString*)aString
range: (
NSRange)rangep
error: (out
NSError**)error;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
groupingSeparator;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSUInteger)
groupingSize;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (BOOL)
hasThousandSeparators;
Availability: MacOS-X 10.0.0
Returns whether thousands separator should be used,
regardless of whether it is set in format.
(Default is YES
if explicitly set in
format.)
- (
NSString*)
internationalCurrencySymbol;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (BOOL)
isLenient;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (BOOL)
isPartialStringValidationEnabled;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (NSLocale*)
locale;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (BOOL)
localizesFormat;
Availability: MacOS-X 10.0.0
Returns whether this format should defer to the
locale in determining thousands separator and
decimal point. The default is to NOT localize.
- (
NSDecimalNumber*)
maximum;
Availability: MacOS-X 10.0.0
Returns maximum value that will be accepted as
valid in number parsing. Default is none.
- (
NSUInteger)
maximumFractionDigits;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSUInteger)
maximumIntegerDigits;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSUInteger)
maximumSignificantDigits;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSDecimalNumber*)
minimum;
Availability: MacOS-X 10.0.0
Returns minimum value that will be accepted as
valid in number parsing. Default is none.
- (
NSUInteger)
minimumFractionDigits;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSUInteger)
minimumIntegerDigits;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSUInteger)
minimumSignificantDigits;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
minusSign;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSNumber*)
multiplier;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
negativeFormat;
Availability: MacOS-X 10.0.0
Returns format used for negative numbers.
- (
NSString*)
negativeInfinitySymbol;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
negativePrefix;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
negativeSuffix;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
nilSymbol;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
notANumberSymbol;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSNumber*)
numberFromString: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Returns the number for this string.
- (
NSString*)
paddingCharacter;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
perMillSymbol;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
percentSymbol;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
plusSign;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
positiveFormat;
Availability: MacOS-X 10.0.0
Returns format used for positive numbers.
- (
NSString*)
positiveInfinitySymbol;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
positivePrefix;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
positiveSuffix;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSNumber*)
roundingIncrement;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSUInteger)
secondaryGroupingSize;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setAllowsFloats: (BOOL)flag;
Availability: MacOS-X 10.0.0
Sets whether number parsing will accept floating point
values or generate an exception (only
int values are valid). Default is
YES
.
- (void)
setAlwaysShowsDecimalSeparator: (BOOL)flag;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setAttributedStringForNil: (
NSAttributedString*)newAttributedString;
Availability: MacOS-X 10.0.0
Sets the exact attributed string used for
nil
values. By default this is an empty
string.
- (void)
setAttributedStringForNotANumber: (
NSAttributedString*)newAttributedString;
Availability: MacOS-X 10.0.0
Sets the exact attributed string used for NaN values.
By default this is the string "NaN" with no attributes.
- (void)
setAttributedStringForZero: (
NSAttributedString*)newAttributedString;
Availability: MacOS-X 10.0.0
Sets the exact attributed string used for zero values.
By default this is based on the format for zero values,
if set, or the format for positive values otherwise.
- (void)
setCurrencyCode: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setCurrencyDecimalSeparator: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setCurrencyGroupingSeparator: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setCurrencySymbol: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setDecimalSeparator: (
NSString*)newSeparator;
Availability: MacOS-X 10.0.0
Sets thousands separator used; default is '.'.
- (void)
setExponentSymbol: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setFormat: (
NSString*)aFormat;
Availability: MacOS-X 10.0.0
Sets format string. See class description for more
information.
- (void)
setFormatWidth: (
NSUInteger)number;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setFormatterBehavior: (
NSNumberFormatterBehavior)behavior;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setGeneratesDecimalNumbers: (BOOL)flag;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setGroupingSeparator: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setGroupingSize: (
NSUInteger)number;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setHasThousandSeparators: (BOOL)flag;
Availability: MacOS-X 10.0.0
Sets whether thousands separator should be used,
regardless of whether it is set in format.
(Default is YES
if explicitly set in
format.)
- (void)
setInternationalCurrencySymbol: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setLenient: (BOOL)flag;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setLocale: (NSLocale*)locale;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setLocalizesFormat: (BOOL)flag;
Availability: MacOS-X 10.0.0
Set whether this format should defer to the locale in
determining thousands separator and decimal
point. The default is to NOT localize.
- (void)
setMaximum: (
NSDecimalNumber*)aMaximum;
Availability: MacOS-X 10.0.0
Sets maximum value that will be accepted as valid in
number parsing. Default is none.
- (void)
setMaximumFractionDigits: (
NSUInteger)number;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setMaximumIntegerDigits: (
NSUInteger)number;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setMaximumSignificantDigits: (
NSUInteger)number;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setMinimum: (
NSDecimalNumber*)aMinimum;
Availability: MacOS-X 10.0.0
Sets minimum value that will be accepted as valid in
number parsing. Default is none.
- (void)
setMinimumFractionDigits: (
NSUInteger)number;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setMinimumIntegerDigits: (
NSUInteger)number;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setMinimumSignificantDigits: (
NSUInteger)number;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setMinusSign: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setMultiplier: (
NSNumber*)number;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setNegativeFormat: (
NSString*)aFormat;
Availability: MacOS-X 10.0.0
Sets format used for negative numbers. See class
description for more information.
- (void)
setNegativeInfinitySymbol: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setNegativePrefix: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setNegativeSuffix: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setNilSymbol: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setNotANumberSymbol: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setNumberStyle: (
NSNumberFormatterStyle)style;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setPaddingCharacter: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setPartialStringValidationEnabled: (BOOL)enabled;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setPerMillSymbol: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setPercentSymbol: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setPlusSign: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setPositiveFormat: (
NSString*)aFormat;
Availability: MacOS-X 10.0.0
Sets format used for positive numbers. See class
description for more information.
- (void)
setPositiveInfinitySymbol: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setPositivePrefix: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setPositiveSuffix: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setRoundingIncrement: (
NSNumber*)number;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setSecondaryGroupingSize: (
NSUInteger)number;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setTextAttributesForNegativeInfinity: (
NSDictionary*)newAttributes;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setTextAttributesForNegativeValues: (
NSDictionary*)newAttributes;
Availability: MacOS-X 10.0.0
- (void)
setTextAttributesForNil: (
NSDictionary*)newAttributes;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setTextAttributesForNotANumber: (
NSDictionary*)newAttributes;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setTextAttributesForPositiveInfinity: (
NSDictionary*)newAttributes;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setTextAttributesForPositiveValues: (
NSDictionary*)newAttributes;
Availability: MacOS-X 10.0.0
- (void)
setTextAttributesForZero: (
NSDictionary*)newAttributes;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setThousandSeparator: (
NSString*)newSeparator;
Availability: MacOS-X 10.0.0
Sets thousands separator used; default is ','.
- (void)
setUsesGroupingSeparator: (BOOL)flag;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setUsesSignificantDigits: (BOOL)flag;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
setZeroSymbol: (
NSString*)string;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
stringFromNumber: (
NSNumber*)number;
Availability: Not in OpenStep/MacOS-X
Returns the string version of this
number based on the format specified.
- (
NSDictionary*)
textAttributesForNegativeInfinity;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSDictionary*)
textAttributesForNegativeValues;
Availability: MacOS-X 10.0.0
- (
NSDictionary*)
textAttributesForNil;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSDictionary*)
textAttributesForNotANumber;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSDictionary*)
textAttributesForPositiveInfinity;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSDictionary*)
textAttributesForPositiveValues;
Availability: MacOS-X 10.0.0
- (
NSDictionary*)
textAttributesForZero;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
thousandSeparator;
Availability: MacOS-X 10.0.0
Returns thousands separator used; default is ','.
- (BOOL)
usesGroupingSeparator;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (BOOL)
usesSignificantDigits;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (
NSString*)
zeroSymbol;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
Up