Skip to content

Commit 55bb3a3

Browse files
committed
Implement copy() in NumberFormatter.
1 parent 1585dca commit 55bb3a3

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

Sources/Foundation/NumberFormatter.swift

+81
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,87 @@ open class NumberFormatter : Formatter {
6666
}
6767
}
6868

69+
open override func copy(with zone: NSZone? = nil) -> Any {
70+
let copied = NumberFormatter()
71+
72+
func __copy<T>(_ keyPath: ReferenceWritableKeyPath<NumberFormatter, T>) {
73+
copied[keyPath: keyPath] = self[keyPath: keyPath]
74+
}
75+
76+
func __copy<T>(_ keyPath: ReferenceWritableKeyPath<NumberFormatter, T>) where T: NSCopying {
77+
copied[keyPath: keyPath] = self[keyPath: keyPath].copy(with: zone) as! T
78+
}
79+
80+
func __copy<T>(_ keyPath: ReferenceWritableKeyPath<NumberFormatter, T?>) where T: NSCopying {
81+
copied[keyPath: keyPath] = self[keyPath: keyPath]?.copy(with: zone) as! T?
82+
}
83+
84+
__copy(\.formattingContext)
85+
__copy(\._numberStyle)
86+
__copy(\._locale)
87+
__copy(\._generatesDecimalNumbers)
88+
__copy(\._textAttributesForNegativeValues)
89+
__copy(\._textAttributesForPositiveValues)
90+
__copy(\._allowsFloats)
91+
__copy(\._decimalSeparator)
92+
__copy(\._alwaysShowsDecimalSeparator)
93+
__copy(\._currencyDecimalSeparator)
94+
__copy(\._usesGroupingSeparator)
95+
__copy(\._groupingSeparator)
96+
__copy(\._zeroSymbol)
97+
__copy(\._textAttributesForZero)
98+
__copy(\._nilSymbol)
99+
__copy(\._textAttributesForNil)
100+
__copy(\._notANumberSymbol)
101+
__copy(\._textAttributesForNotANumber)
102+
__copy(\._positiveInfinitySymbol)
103+
__copy(\._textAttributesForPositiveInfinity)
104+
__copy(\._negativeInfinitySymbol)
105+
__copy(\._textAttributesForNegativeInfinity)
106+
__copy(\._positivePrefix)
107+
__copy(\._positiveSuffix)
108+
__copy(\._negativePrefix)
109+
__copy(\._negativeSuffix)
110+
__copy(\._currencyCode)
111+
__copy(\._currencySymbol)
112+
__copy(\._internationalCurrencySymbol)
113+
__copy(\._percentSymbol)
114+
__copy(\._perMillSymbol)
115+
__copy(\._minusSign)
116+
__copy(\._plusSign)
117+
__copy(\._exponentSymbol)
118+
__copy(\._groupingSize)
119+
__copy(\._secondaryGroupingSize)
120+
__copy(\._multiplier)
121+
__copy(\._formatWidth)
122+
__copy(\._paddingCharacter)
123+
__copy(\._paddingPosition)
124+
__copy(\._roundingMode)
125+
__copy(\._roundingIncrement)
126+
__copy(\._minimumIntegerDigits)
127+
__copy(\._maximumIntegerDigits)
128+
__copy(\._minimumFractionDigits)
129+
__copy(\._maximumFractionDigits)
130+
__copy(\._minimum)
131+
__copy(\._maximum)
132+
__copy(\._currencyGroupingSeparator)
133+
__copy(\._lenient)
134+
__copy(\._usesSignificantDigits)
135+
__copy(\._minimumSignificantDigits)
136+
__copy(\._maximumSignificantDigits)
137+
__copy(\._partialStringValidationEnabled)
138+
__copy(\._hasThousandSeparators)
139+
__copy(\._thousandSeparator)
140+
__copy(\._localizesFormat)
141+
__copy(\._positiveFormat)
142+
__copy(\._negativeFormat)
143+
__copy(\._attributedStringForZero)
144+
__copy(\._attributedStringForNotANumber)
145+
__copy(\._roundingBehavior)
146+
147+
return copied
148+
}
149+
69150
// this is for NSUnitFormatter
70151

71152
open var formattingContext: Context = .unknown // default is NSFormattingContextUnknown

0 commit comments

Comments
 (0)