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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426
|
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016, 2019 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
@_implementationOnly import CoreFoundation
internal import Synchronization
extension NumberFormatter {
public enum Style : UInt, Sendable {
case none = 0
case decimal = 1
case currency = 2
case percent = 3
case scientific = 4
case spellOut = 5
case ordinal = 6
case currencyISOCode = 8 // 7 is not used
case currencyPlural = 9
case currencyAccounting = 10
}
public enum PadPosition : UInt, Sendable {
case beforePrefix
case afterPrefix
case beforeSuffix
case afterSuffix
}
public enum RoundingMode : UInt, Sendable {
case ceiling
case floor
case down
case up
case halfEven
case halfDown
case halfUp
}
}
open class NumberFormatter : Formatter, @unchecked Sendable {
private let _lock: Mutex<State> = .init(.init())
public override init() {
super.init()
}
public required init?(coder: NSCoder) {
super.init(coder: coder)
}
private convenience init(state: State) {
self.init()
_lock.withLock {
$0 = state
}
}
open override func copy(with zone: NSZone? = nil) -> Any {
return _lock.withLock { state in
// Zone is not Sendable, so just ignore it here
let copy = state.copy()
return NumberFormatter(state: copy)
}
}
open class func localizedString(from num: NSNumber, number nstyle: Style) -> String {
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = nstyle
return numberFormatter.string(for: num)!
}
// This class is not Sendable, but marking it as such was the only way to work around compiler crashes while attempting to use `~Copyable` like `DateFormatter` does.
final class State : @unchecked Sendable {
class Box {
var formatter: CFNumberFormatter?
init() {}
}
private var _formatter = Box()
// MARK: -
func copy(with zone: NSZone? = nil) -> State {
let copied = State()
copied.formattingContext = formattingContext
copied._numberStyle = _numberStyle
copied._locale = _locale
copied._generatesDecimalNumbers = _generatesDecimalNumbers
copied._textAttributesForNegativeValues = _textAttributesForNegativeValues
copied._textAttributesForPositiveValues = _textAttributesForPositiveValues
copied._allowsFloats = _allowsFloats
copied._decimalSeparator = _decimalSeparator
copied._alwaysShowsDecimalSeparator = _alwaysShowsDecimalSeparator
copied._currencyDecimalSeparator = _currencyDecimalSeparator
copied._usesGroupingSeparator = _usesGroupingSeparator
copied._groupingSeparator = _groupingSeparator
copied._zeroSymbol = _zeroSymbol
copied._textAttributesForZero = _textAttributesForZero
copied._nilSymbol = _nilSymbol
copied._textAttributesForNil = _textAttributesForNil
copied._notANumberSymbol = _notANumberSymbol
copied._textAttributesForNotANumber = _textAttributesForNotANumber
copied._positiveInfinitySymbol = _positiveInfinitySymbol
copied._textAttributesForPositiveInfinity = _textAttributesForPositiveInfinity
copied._negativeInfinitySymbol = _negativeInfinitySymbol
copied._textAttributesForNegativeInfinity = _textAttributesForNegativeInfinity
copied._positivePrefix = _positivePrefix
copied._positiveSuffix = _positiveSuffix
copied._negativePrefix = _negativePrefix
copied._negativeSuffix = _negativeSuffix
copied._currencyCode = _currencyCode
copied._currencySymbol = _currencySymbol
copied._internationalCurrencySymbol = _internationalCurrencySymbol
copied._percentSymbol = _percentSymbol
copied._perMillSymbol = _perMillSymbol
copied._minusSign = _minusSign
copied._plusSign = _plusSign
copied._exponentSymbol = _exponentSymbol
copied._groupingSize = _groupingSize
copied._secondaryGroupingSize = _secondaryGroupingSize
copied._multiplier = _multiplier
copied._formatWidth = _formatWidth
copied._paddingCharacter = _paddingCharacter
copied._paddingPosition = _paddingPosition
copied._roundingMode = _roundingMode
copied._roundingIncrement = _roundingIncrement
copied._minimumIntegerDigits = _minimumIntegerDigits
copied._maximumIntegerDigits = _maximumIntegerDigits
copied._minimumFractionDigits = _minimumFractionDigits
copied._maximumFractionDigits = _maximumFractionDigits
copied._minimum = _minimum
copied._maximum = _maximum
copied._currencyGroupingSeparator = _currencyGroupingSeparator
copied._lenient = _lenient
copied._usesSignificantDigits = _usesSignificantDigits
copied._minimumSignificantDigits = _minimumSignificantDigits
copied._maximumSignificantDigits = _maximumSignificantDigits
copied._partialStringValidationEnabled = _partialStringValidationEnabled
copied._hasThousandSeparators = _hasThousandSeparators
copied._thousandSeparator = _thousandSeparator
copied._localizesFormat = _localizesFormat
copied._positiveFormat = _positiveFormat
copied._negativeFormat = _negativeFormat
copied._roundingBehavior = _roundingBehavior
return copied
}
// MARK: -
func _reset() {
_formatter.formatter = nil
}
func formatter() -> CFNumberFormatter {
if let obj = _formatter.formatter {
return obj
} else {
let numberStyle = CFNumberFormatterStyle(rawValue: CFIndex(_numberStyle.rawValue))!
let obj = CFNumberFormatterCreate(kCFAllocatorSystemDefault, locale._cfObject, numberStyle)!
_setFormatterAttributes(obj)
if _positiveFormat != nil || _negativeFormat != nil {
var format = _positiveFormat ?? "#"
if let negative = _negativeFormat {
format.append(";")
format.append(negative)
}
CFNumberFormatterSetFormat(obj, format._cfObject)
}
_formatter.formatter = obj
return obj
}
}
private func _setFormatterAttributes(_ formatter: CFNumberFormatter) {
if numberStyle == .currency {
// Prefer currencySymbol, then currencyCode then locale.currencySymbol
if let symbol = _currencySymbol {
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterCurrencySymbol, value: symbol._cfObject)
} else if let code = _currencyCode, code.count == 3 {
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterCurrencyCode, value: code._cfObject)
} else {
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterCurrencySymbol, value: locale.currencySymbol?._cfObject)
}
}
if numberStyle == .currencyISOCode {
let code = _currencyCode ?? _currencySymbol ?? locale.currencyCode ?? locale.currencySymbol
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterCurrencyCode, value: code?._cfObject)
}
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterDecimalSeparator, value: _decimalSeparator?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterCurrencyDecimalSeparator, value: _currencyDecimalSeparator?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterAlwaysShowDecimalSeparator, value: _alwaysShowsDecimalSeparator._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterGroupingSeparator, value: _groupingSeparator?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterUseGroupingSeparator, value: usesGroupingSeparator._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterPercentSymbol, value: _percentSymbol?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterZeroSymbol, value: _zeroSymbol?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterNaNSymbol, value: _notANumberSymbol?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterInfinitySymbol, value: _positiveInfinitySymbol._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterMinusSign, value: _minusSign?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterPlusSign, value: _plusSign?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterExponentSymbol, value: _exponentSymbol?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterMinIntegerDigits, value: _minimumIntegerDigits?._bridgeToObjectiveC()._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterMaxIntegerDigits, value: _maximumIntegerDigits?._bridgeToObjectiveC()._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterMinFractionDigits, value: _minimumFractionDigits?._bridgeToObjectiveC()._cfObject)
if minimumFractionDigits <= 0 {
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterMaxFractionDigits, value: maximumFractionDigits._bridgeToObjectiveC()._cfObject)
}
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterGroupingSize, value: groupingSize._bridgeToObjectiveC()._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterSecondaryGroupingSize, value: _secondaryGroupingSize._bridgeToObjectiveC()._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterRoundingMode, value: _roundingMode.rawValue._bridgeToObjectiveC()._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterRoundingIncrement, value: _roundingIncrement?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterFormatWidth, value: _formatWidth?._bridgeToObjectiveC()._cfObject)
if self.formatWidth > 0 {
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterPaddingCharacter, value: _paddingCharacter?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterPaddingPosition, value: _paddingPosition.rawValue._bridgeToObjectiveC()._cfObject)
} else {
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterPaddingCharacter, value: ""._cfObject)
}
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterMultiplier, value: multiplier?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterPositivePrefix, value: _positivePrefix?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterPositiveSuffix, value: _positiveSuffix?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterNegativePrefix, value: _negativePrefix?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterNegativeSuffix, value: _negativeSuffix?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterPerMillSymbol, value: _percentSymbol?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterInternationalCurrencySymbol, value: _internationalCurrencySymbol?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterCurrencyGroupingSeparator, value: _currencyGroupingSeparator?._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterIsLenient, value: _lenient._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterUseSignificantDigits, value: usesSignificantDigits._cfObject)
if usesSignificantDigits {
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterMinSignificantDigits, value: minimumSignificantDigits._bridgeToObjectiveC()._cfObject)
_setFormatterAttribute(formatter, attributeName: kCFNumberFormatterMaxSignificantDigits, value: maximumSignificantDigits._bridgeToObjectiveC()._cfObject)
}
}
private func _setFormatterAttribute(_ formatter: CFNumberFormatter, attributeName: CFString, value: AnyObject?) {
if let value = value {
CFNumberFormatterSetProperty(formatter, attributeName, value)
}
}
private func _getFormatterAttribute(attributeName: CFString) -> String? {
// This will only be a constant CFString
nonisolated(unsafe) let nonisolatedAttributeName = attributeName
return CFNumberFormatterCopyProperty(formatter(), nonisolatedAttributeName) as? String
}
private func getFormatterComponents() -> (String?, String?) {
guard let format = CFNumberFormatterGetFormat(formatter())?._swiftObject else {
return (nil, nil)
}
let components = format.components(separatedBy: ";")
let positive = _positiveFormat ?? components.first ?? "#"
let negative = _negativeFormat ?? components.last ?? "#"
return (positive, negative)
}
// MARK: - Properties
private var _numberStyle: Style = .none
var numberStyle: Style {
get {
return _numberStyle
}
set {
_reset()
_numberStyle = newValue
}
}
private var _locale: Locale = Locale.current
var locale: Locale! {
get {
return _locale
}
set {
_reset()
_locale = newValue
}
}
private var _generatesDecimalNumbers: Bool = false
var generatesDecimalNumbers: Bool {
get {
return _generatesDecimalNumbers
}
set {
_reset()
_generatesDecimalNumbers = newValue
}
}
private var _textAttributesForNegativeValues: [String : (Any & Sendable)]?
var textAttributesForNegativeValues: [String : (Any & Sendable)]? {
get {
return _textAttributesForNegativeValues
}
set {
_reset()
_textAttributesForNegativeValues = newValue
}
}
private var _textAttributesForPositiveValues: [String : (Any & Sendable)]?
var textAttributesForPositiveValues: [String : (Any & Sendable)]? {
get {
return _textAttributesForPositiveValues
}
set {
_reset()
_textAttributesForPositiveValues = newValue
}
}
private var _allowsFloats: Bool = true
var allowsFloats: Bool {
get {
return _allowsFloats
}
set {
_reset()
_allowsFloats = newValue
}
}
private var _decimalSeparator: String!
var decimalSeparator: String! {
get {
return _decimalSeparator ?? _getFormatterAttribute(attributeName: kCFNumberFormatterDecimalSeparator)
}
set {
_reset()
_decimalSeparator = newValue
}
}
private var _alwaysShowsDecimalSeparator: Bool = false
var alwaysShowsDecimalSeparator: Bool {
get {
return _alwaysShowsDecimalSeparator
}
set {
_reset()
_alwaysShowsDecimalSeparator = newValue
}
}
private var _currencyDecimalSeparator: String!
var currencyDecimalSeparator: String! {
get {
return _currencyDecimalSeparator ?? _getFormatterAttribute(attributeName: kCFNumberFormatterCurrencyDecimalSeparator)
}
set {
_reset()
_currencyDecimalSeparator = newValue
}
}
private var _usesGroupingSeparator: Bool?
var usesGroupingSeparator: Bool {
get {
return _usesGroupingSeparator ?? defaultUsesGroupingSeparator()
}
set {
_reset()
_usesGroupingSeparator = newValue
}
}
private var _groupingSeparator: String!
var groupingSeparator: String! {
get {
return _groupingSeparator ?? _getFormatterAttribute(attributeName: kCFNumberFormatterGroupingSeparator)
}
set {
_reset()
_groupingSeparator = newValue
}
}
private var _zeroSymbol: String?
var zeroSymbol: String? {
get {
return _zeroSymbol
}
set {
_reset()
_zeroSymbol = newValue
}
}
private var _textAttributesForZero: [String : (Any & Sendable)]?
var textAttributesForZero: [String : (Any & Sendable)]? {
get {
return _textAttributesForZero
}
set {
_reset()
_textAttributesForZero = newValue
}
}
private var _nilSymbol: String = ""
var nilSymbol: String {
get {
return _nilSymbol
}
set {
_reset()
_nilSymbol = newValue
}
}
private var _textAttributesForNil: [String : (Any & Sendable)]?
var textAttributesForNil: [String : (Any & Sendable)]? {
get {
return _textAttributesForNil
}
set {
_reset()
_textAttributesForNil = newValue
}
}
private var _notANumberSymbol: String!
var notANumberSymbol: String! {
get {
return _notANumberSymbol ?? _getFormatterAttribute(attributeName: kCFNumberFormatterNaNSymbol)
}
set {
_reset()
_notANumberSymbol = newValue
}
}
private var _textAttributesForNotANumber: [String : (Any & Sendable)]?
var textAttributesForNotANumber: [String : (Any & Sendable)]? {
get {
return _textAttributesForNotANumber
}
set {
_reset()
_textAttributesForNotANumber = newValue
}
}
private var _positiveInfinitySymbol: String = "+∞"
var positiveInfinitySymbol: String {
get {
return _positiveInfinitySymbol
}
set {
_reset()
_positiveInfinitySymbol = newValue
}
}
private var _textAttributesForPositiveInfinity: [String : (Any & Sendable)]?
var textAttributesForPositiveInfinity: [String : (Any & Sendable)]? {
get {
return _textAttributesForPositiveInfinity
}
set {
_reset()
_textAttributesForPositiveInfinity = newValue
}
}
private var _negativeInfinitySymbol: String = "-∞"
var negativeInfinitySymbol: String {
get {
return _negativeInfinitySymbol
}
set {
_reset()
_negativeInfinitySymbol = newValue
}
}
private var _textAttributesForNegativeInfinity: [String : (Any & Sendable)]?
var textAttributesForNegativeInfinity: [String : (Any & Sendable)]? {
get {
return _textAttributesForNegativeInfinity
}
set {
_reset()
_textAttributesForNegativeInfinity = newValue
}
}
private var _positivePrefix: String!
var positivePrefix: String! {
get {
return _positivePrefix ?? _getFormatterAttribute(attributeName: kCFNumberFormatterPositivePrefix)
}
set {
_reset()
_positivePrefix = newValue
}
}
private var _positiveSuffix: String!
var positiveSuffix: String! {
get {
return _positiveSuffix ?? _getFormatterAttribute(attributeName: kCFNumberFormatterPositiveSuffix)
}
set {
_reset()
_positiveSuffix = newValue
}
}
private var _negativePrefix: String!
var negativePrefix: String! {
get {
return _negativePrefix ?? _getFormatterAttribute(attributeName: kCFNumberFormatterNegativePrefix)
}
set {
_reset()
_negativePrefix = newValue
}
}
private var _negativeSuffix: String!
var negativeSuffix: String! {
get {
return _negativeSuffix ?? _getFormatterAttribute(attributeName: kCFNumberFormatterNegativeSuffix)
}
set {
_reset()
_negativeSuffix = newValue
}
}
private var _currencyCode: String!
var currencyCode: String! {
get {
return _currencyCode ?? _getFormatterAttribute(attributeName: kCFNumberFormatterCurrencyCode)
}
set {
_reset()
_currencyCode = newValue
}
}
private var _currencySymbol: String!
var currencySymbol: String! {
get {
return _currencySymbol ?? _getFormatterAttribute(attributeName: kCFNumberFormatterCurrencySymbol)
}
set {
_reset()
_currencySymbol = newValue
}
}
private var _internationalCurrencySymbol: String!
var internationalCurrencySymbol: String! {
get {
return _internationalCurrencySymbol ?? _getFormatterAttribute(attributeName: kCFNumberFormatterInternationalCurrencySymbol)
}
set {
_reset()
_internationalCurrencySymbol = newValue
}
}
private var _percentSymbol: String!
var percentSymbol: String! {
get {
return _percentSymbol ?? _getFormatterAttribute(attributeName: kCFNumberFormatterPercentSymbol) ?? "%"
}
set {
_reset()
_percentSymbol = newValue
}
}
private var _perMillSymbol: String!
var perMillSymbol: String! {
get {
return _perMillSymbol ?? _getFormatterAttribute(attributeName: kCFNumberFormatterPerMillSymbol)
}
set {
_reset()
_perMillSymbol = newValue
}
}
private var _minusSign: String!
var minusSign: String! {
get {
return _minusSign ?? _getFormatterAttribute(attributeName: kCFNumberFormatterMinusSign)
}
set {
_reset()
_minusSign = newValue
}
}
private var _plusSign: String!
var plusSign: String! {
get {
return _plusSign ?? _getFormatterAttribute(attributeName: kCFNumberFormatterPlusSign)
}
set {
_reset()
_plusSign = newValue
}
}
private var _exponentSymbol: String!
var exponentSymbol: String! {
get {
return _exponentSymbol ?? _getFormatterAttribute(attributeName: kCFNumberFormatterExponentSymbol)
}
set {
_reset()
_exponentSymbol = newValue
}
}
private var _groupingSize: Int?
var groupingSize: Int {
get {
return _groupingSize ?? defaultGroupingSize()
}
set {
_reset()
_groupingSize = newValue
}
}
private var _secondaryGroupingSize: Int = 0
var secondaryGroupingSize: Int {
get {
return _secondaryGroupingSize
}
set {
_reset()
_secondaryGroupingSize = newValue
}
}
private var _multiplier: NSNumber?
var multiplier: NSNumber? {
get {
return _multiplier ?? defaultMultiplier()
}
set {
_reset()
_multiplier = newValue
}
}
private var _formatWidth: Int?
var formatWidth: Int {
get {
return _formatWidth ?? defaultFormatWidth()
}
set {
_reset()
_formatWidth = newValue
}
}
private var _paddingCharacter: String! = " "
var paddingCharacter: String! {
get {
return _paddingCharacter ?? _getFormatterAttribute(attributeName: kCFNumberFormatterPaddingCharacter)
}
set {
_reset()
_paddingCharacter = newValue
}
}
private var _paddingPosition: PadPosition = .beforePrefix
var paddingPosition: PadPosition {
get {
return _paddingPosition
}
set {
_reset()
_paddingPosition = newValue
}
}
private var _roundingMode: RoundingMode = .halfEven
var roundingMode: RoundingMode {
get {
return _roundingMode
}
set {
_reset()
_roundingMode = newValue
}
}
private var _roundingIncrement: NSNumber! = 0
var roundingIncrement: NSNumber! {
get {
return _roundingIncrement
}
set {
_reset()
_roundingIncrement = newValue
}
}
// Use an optional for _minimumIntegerDigits to track if the value is
// set BEFORE the .numberStyle is changed. This allows preserving a setting
// of 0.
private var _minimumIntegerDigits: Int?
var minimumIntegerDigits: Int {
get {
return _minimumIntegerDigits ?? defaultMinimumIntegerDigits()
}
set {
_reset()
_minimumIntegerDigits = newValue
}
}
private var _maximumIntegerDigits: Int?
var maximumIntegerDigits: Int {
get {
return _maximumIntegerDigits ?? defaultMaximumIntegerDigits()
}
set {
_reset()
_maximumIntegerDigits = newValue
}
}
private var _minimumFractionDigits: Int?
var minimumFractionDigits: Int {
get {
return _minimumFractionDigits ?? defaultMinimumFractionDigits()
}
set {
_reset()
_minimumFractionDigits = newValue
}
}
private var _maximumFractionDigits: Int?
var maximumFractionDigits: Int {
get {
return _maximumFractionDigits ?? defaultMaximumFractionDigits()
}
set {
_reset()
_maximumFractionDigits = newValue
}
}
private var _minimum: NSNumber?
var minimum: NSNumber? {
get {
return _minimum
}
set {
_reset()
_minimum = newValue
}
}
private var _maximum: NSNumber?
var maximum: NSNumber? {
get {
return _maximum
}
set {
_reset()
_maximum = newValue
}
}
private var _currencyGroupingSeparator: String!
var currencyGroupingSeparator: String! {
get {
return _currencyGroupingSeparator ?? _getFormatterAttribute(attributeName: kCFNumberFormatterCurrencyGroupingSeparator)
}
set {
_reset()
_currencyGroupingSeparator = newValue
}
}
private var _lenient: Bool = false
var isLenient: Bool {
get {
return _lenient
}
set {
_reset()
_lenient = newValue
}
}
private var _usesSignificantDigits: Bool?
var usesSignificantDigits: Bool {
get {
return _usesSignificantDigits ?? false
}
set {
_reset()
_usesSignificantDigits = newValue
}
}
private var _minimumSignificantDigits: Int?
var minimumSignificantDigits: Int {
get {
return _minimumSignificantDigits ?? defaultMinimumSignificantDigits()
}
set {
_reset()
_usesSignificantDigits = true
_minimumSignificantDigits = newValue
if _maximumSignificantDigits == nil && newValue > defaultMinimumSignificantDigits() {
_maximumSignificantDigits = (newValue < 1000) ? 999 : newValue
}
}
}
private var _maximumSignificantDigits: Int?
var maximumSignificantDigits: Int {
get {
return _maximumSignificantDigits ?? defaultMaximumSignificantDigits()
}
set {
_reset()
_usesSignificantDigits = true
_maximumSignificantDigits = newValue
}
}
private var _partialStringValidationEnabled: Bool = false
var isPartialStringValidationEnabled: Bool {
get {
return _partialStringValidationEnabled
}
set {
_reset()
_partialStringValidationEnabled = newValue
}
}
private var _hasThousandSeparators: Bool = false
var hasThousandSeparators: Bool {
get {
return _hasThousandSeparators
}
set {
_reset()
_hasThousandSeparators = newValue
}
}
private var _thousandSeparator: String!
var thousandSeparator: String! {
get {
return _thousandSeparator
}
set {
_reset()
_thousandSeparator = newValue
}
}
private var _localizesFormat: Bool = true
var localizesFormat: Bool {
get {
return _localizesFormat
}
set {
_reset()
_localizesFormat = newValue
}
}
private var _positiveFormat: String!
var positiveFormat: String! {
get {
return getFormatterComponents().0
}
set {
_reset()
_positiveFormat = newValue
}
}
private var _negativeFormat: String!
var negativeFormat: String! {
get {
return getFormatterComponents().1
}
set {
_reset()
_negativeFormat = newValue
}
}
private var _roundingBehavior: NSDecimalNumberHandler = NSDecimalNumberHandler.default
var roundingBehavior: NSDecimalNumberHandler {
get {
return _roundingBehavior
}
set {
_reset()
_roundingBehavior = newValue
}
}
private func getZeroFormat() -> String {
return string(from: 0) ?? "0"
}
var format: String {
get {
let (p, n) = getFormatterComponents()
let z = _zeroSymbol ?? getZeroFormat()
return "\(p ?? "(null)");\(z);\(n ?? "(null)")"
}
set {
// Special case empty string
if newValue == "" {
_positiveFormat = ""
_negativeFormat = "-"
_zeroSymbol = "0"
_reset()
} else {
let components = newValue.components(separatedBy: ";")
let count = components.count
guard count <= 3 else { return }
_reset()
_positiveFormat = components.first ?? ""
if count == 1 {
_negativeFormat = "-\(_positiveFormat ?? "")"
}
else if count == 2 {
_negativeFormat = components[1]
_zeroSymbol = getZeroFormat()
}
else if count == 3 {
_zeroSymbol = components[1]
_negativeFormat = components[2]
}
if _negativeFormat == nil {
_negativeFormat = getFormatterComponents().1
}
if _zeroSymbol == nil {
_zeroSymbol = getZeroFormat()
}
}
}
}
// this is for NSUnitFormatter
var formattingContext: Context = .unknown // default is NSFormattingContextUnknown
func string(for obj: Any) -> String? {
//we need to allow Swift's numeric types here - Int, Double et al.
guard let number = __SwiftValue.store(obj) as? NSNumber else { return nil }
return string(from: number)
}
// Even though NumberFormatter responds to the usual Formatter methods,
// here are some convenience methods which are a little more obvious.
func string(from number: NSNumber) -> String? {
return CFNumberFormatterCreateStringWithNumber(kCFAllocatorSystemDefault, formatter(), number._cfObject)._swiftObject
}
func number(from string: String) -> NSNumber? {
var range = CFRange(location: 0, length: string.length)
let number = withUnsafeMutablePointer(to: &range) { (rangePointer: UnsafeMutablePointer<CFRange>) -> NSNumber? in
let parseOption = allowsFloats ? 0 : CFNumberFormatterOptionFlags.parseIntegersOnly.rawValue
let result = CFNumberFormatterCreateNumberFromString(kCFAllocatorSystemDefault, formatter(), string._cfObject, rangePointer, parseOption)
return result?._nsObject
}
return number
}
// Attributes of a NumberFormatter. Many attributes have default values but if they are set by the caller
// the new value needs to be retained even if the .numberStyle is changed. Attributes are backed by an optional
// to indicate to use the default value (if nil) or the caller-supplied value (if not nil).
private func defaultMinimumIntegerDigits() -> Int {
switch numberStyle {
case .ordinal, .spellOut, .currencyPlural:
return 0
case .none, .currency, .currencyISOCode, .currencyAccounting, .decimal, .percent, .scientific:
return 1
}
}
private func defaultMaximumIntegerDigits() -> Int {
switch numberStyle {
case .none:
return 42
case .ordinal, .spellOut, .currencyPlural:
return 0
case .currency, .currencyISOCode, .currencyAccounting, .decimal, .percent:
return 2_000_000_000
case .scientific:
return 1
}
}
private func defaultMinimumFractionDigits() -> Int {
switch numberStyle {
case .none, .ordinal, .spellOut, .currencyPlural, .decimal, .percent, .scientific:
return 0
case .currency, .currencyISOCode, .currencyAccounting:
return 2
}
}
private func defaultMaximumFractionDigits() -> Int {
switch numberStyle {
case .none, .ordinal, .spellOut, .currencyPlural, .percent, .scientific:
return 0
case .currency, .currencyISOCode, .currencyAccounting:
return 2
case .decimal:
return 3
}
}
private func defaultMinimumSignificantDigits() -> Int {
switch numberStyle {
case .ordinal, .spellOut, .currencyPlural:
return 0
case .currency, .none, .currencyISOCode, .currencyAccounting, .decimal, .percent, .scientific:
return -1
}
}
private func defaultMaximumSignificantDigits() -> Int {
switch numberStyle {
case .none, .currency, .currencyISOCode, .currencyAccounting, .decimal, .percent, .scientific:
return -1
case .ordinal, .spellOut, .currencyPlural:
return 0
}
}
private func defaultUsesGroupingSeparator() -> Bool {
switch numberStyle {
case .none, .scientific, .spellOut, .ordinal, .currencyPlural:
return false
case .decimal, .currency, .percent, .currencyAccounting, .currencyISOCode:
return true
}
}
private func defaultGroupingSize() -> Int {
switch numberStyle {
case .none, .ordinal, .spellOut, .currencyPlural, .scientific:
return 0
case .currency, .currencyISOCode, .currencyAccounting, .decimal, .percent:
return 3
}
}
private func defaultMultiplier() -> NSNumber? {
switch numberStyle {
case .percent: return NSNumber(100)
default: return nil
}
}
private func defaultFormatWidth() -> Int {
switch numberStyle {
case .ordinal, .spellOut, .currencyPlural:
return 0
case .none, .decimal, .currency, .percent, .scientific, .currencyISOCode, .currencyAccounting:
return -1
}
}
}
// MARK: -
open func string(from number: NSNumber) -> String? {
_lock.withLock { $0.string(from: number) }
}
open func number(from string: String) -> NSNumber? {
_lock.withLock { $0.number(from: string) }
}
open override func string(for obj: Any) -> String? {
//we need to allow Swift's numeric types here - Int, Double et al.
guard let number = __SwiftValue.store(obj) as? NSNumber else { return nil }
return string(from: number)
}
open var numberStyle: Style {
get { _lock.withLock { $0.numberStyle } }
set { _lock.withLock { $0.numberStyle = newValue } }
}
open var locale: Locale! {
get { _lock.withLock { $0.locale } }
set { _lock.withLock { $0.locale = newValue } }
}
open var generatesDecimalNumbers: Bool {
get { _lock.withLock { $0.generatesDecimalNumbers } }
set { _lock.withLock { $0.generatesDecimalNumbers = newValue } }
}
open var textAttributesForNegativeValues: [String : (Any & Sendable)]? {
get { _lock.withLock { $0.textAttributesForNegativeValues } }
set { _lock.withLock { $0.textAttributesForNegativeValues = newValue } }
}
open var textAttributesForPositiveValues: [String : (Any & Sendable)]? {
get { _lock.withLock { $0.textAttributesForPositiveValues } }
set { _lock.withLock { $0.textAttributesForPositiveValues = newValue } }
}
open var allowsFloats: Bool {
get { _lock.withLock { $0.allowsFloats } }
set { _lock.withLock { $0.allowsFloats = newValue } }
}
open var decimalSeparator: String! {
get { _lock.withLock { $0.decimalSeparator } }
set { _lock.withLock { $0.decimalSeparator = newValue } }
}
open var alwaysShowsDecimalSeparator: Bool {
get { _lock.withLock { $0.alwaysShowsDecimalSeparator } }
set { _lock.withLock { $0.alwaysShowsDecimalSeparator = newValue } }
}
open var currencyDecimalSeparator: String! {
get { _lock.withLock { $0.currencyDecimalSeparator } }
set { _lock.withLock { $0.currencyDecimalSeparator = newValue } }
}
open var usesGroupingSeparator: Bool {
get { _lock.withLock { $0.usesGroupingSeparator } }
set { _lock.withLock { $0.usesGroupingSeparator = newValue } }
}
open var groupingSeparator: String! {
get { _lock.withLock { $0.groupingSeparator } }
set { _lock.withLock { $0.groupingSeparator = newValue } }
}
open var zeroSymbol: String? {
get { _lock.withLock { $0.zeroSymbol } }
set { _lock.withLock { $0.zeroSymbol = newValue } }
}
open var textAttributesForZero: [String : (Any & Sendable)]? {
get { _lock.withLock { $0.textAttributesForZero } }
set { _lock.withLock { $0.textAttributesForZero = newValue } }
}
open var nilSymbol: String {
get { _lock.withLock { $0.nilSymbol } }
set { _lock.withLock { $0.nilSymbol = newValue } }
}
open var textAttributesForNil: [String : (Any & Sendable)]? {
get { _lock.withLock { $0.textAttributesForNil } }
set { _lock.withLock { $0.textAttributesForNil = newValue } }
}
open var notANumberSymbol: String! {
get { _lock.withLock { $0.notANumberSymbol } }
set { _lock.withLock { $0.notANumberSymbol = newValue } }
}
open var textAttributesForNotANumber: [String : (Any & Sendable)]? {
get { _lock.withLock { $0.textAttributesForNotANumber } }
set { _lock.withLock { $0.textAttributesForNotANumber = newValue } }
}
open var positiveInfinitySymbol: String {
get { _lock.withLock { $0.positiveInfinitySymbol } }
set { _lock.withLock { $0.positiveInfinitySymbol = newValue } }
}
open var textAttributesForPositiveInfinity: [String : (Any & Sendable)]? {
get { _lock.withLock { $0.textAttributesForPositiveInfinity } }
set { _lock.withLock { $0.textAttributesForPositiveInfinity = newValue } }
}
open var negativeInfinitySymbol: String {
get { _lock.withLock { $0.negativeInfinitySymbol } }
set { _lock.withLock { $0.negativeInfinitySymbol = newValue } }
}
open var textAttributesForNegativeInfinity: [String : (Any & Sendable)]? {
get { _lock.withLock { $0.textAttributesForNegativeInfinity } }
set { _lock.withLock { $0.textAttributesForNegativeInfinity = newValue } }
}
open var positivePrefix: String! {
get { _lock.withLock { $0.positivePrefix } }
set { _lock.withLock { $0.positivePrefix = newValue } }
}
open var positiveSuffix: String! {
get { _lock.withLock { $0.positiveSuffix } }
set { _lock.withLock { $0.positiveSuffix = newValue } }
}
open var negativePrefix: String! {
get { _lock.withLock { $0.negativePrefix } }
set { _lock.withLock { $0.negativePrefix = newValue } }
}
open var negativeSuffix: String! {
get { _lock.withLock { $0.negativeSuffix } }
set { _lock.withLock { $0.negativeSuffix = newValue } }
}
open var currencyCode: String! {
get { _lock.withLock { $0.currencyCode } }
set { _lock.withLock { $0.currencyCode = newValue } }
}
open var currencySymbol: String! {
get { _lock.withLock { $0.currencySymbol } }
set { _lock.withLock { $0.currencySymbol = newValue } }
}
open var internationalCurrencySymbol: String! {
get { _lock.withLock { $0.internationalCurrencySymbol } }
set { _lock.withLock { $0.internationalCurrencySymbol = newValue } }
}
open var percentSymbol: String! {
get { _lock.withLock { $0.percentSymbol } }
set { _lock.withLock { $0.percentSymbol = newValue } }
}
open var perMillSymbol: String! {
get { _lock.withLock { $0.perMillSymbol } }
set { _lock.withLock { $0.perMillSymbol = newValue } }
}
open var minusSign: String! {
get { _lock.withLock { $0.minusSign } }
set { _lock.withLock { $0.minusSign = newValue } }
}
open var plusSign: String! {
get { _lock.withLock { $0.plusSign } }
set { _lock.withLock { $0.plusSign = newValue } }
}
open var exponentSymbol: String! {
get { _lock.withLock { $0.exponentSymbol } }
set { _lock.withLock { $0.exponentSymbol = newValue } }
}
open var groupingSize: Int {
get { _lock.withLock { $0.groupingSize } }
set { _lock.withLock { $0.groupingSize = newValue } }
}
open var secondaryGroupingSize: Int {
get { _lock.withLock { $0.secondaryGroupingSize } }
set { _lock.withLock { $0.secondaryGroupingSize = newValue } }
}
open var multiplier: NSNumber? {
get { _lock.withLock { $0.multiplier } }
set { _lock.withLock { $0.multiplier = newValue } }
}
open var formatWidth: Int {
get { _lock.withLock { $0.formatWidth } }
set { _lock.withLock { $0.formatWidth = newValue } }
}
open var paddingCharacter: String! {
get { _lock.withLock { $0.paddingCharacter } }
set { _lock.withLock { $0.paddingCharacter = newValue } }
}
open var paddingPosition: PadPosition {
get { _lock.withLock { $0.paddingPosition } }
set { _lock.withLock { $0.paddingPosition = newValue } }
}
open var roundingMode: RoundingMode {
get { _lock.withLock { $0.roundingMode } }
set { _lock.withLock { $0.roundingMode = newValue } }
}
open var roundingIncrement: NSNumber! {
get { _lock.withLock { $0.roundingIncrement } }
set { _lock.withLock { $0.roundingIncrement = newValue } }
}
open var minimumIntegerDigits: Int {
get { _lock.withLock { $0.minimumIntegerDigits } }
set { _lock.withLock { $0.minimumIntegerDigits = newValue } }
}
open var maximumIntegerDigits: Int {
get { _lock.withLock { $0.maximumIntegerDigits } }
set { _lock.withLock { $0.maximumIntegerDigits = newValue } }
}
open var minimumFractionDigits: Int {
get { _lock.withLock { $0.minimumFractionDigits } }
set { _lock.withLock { $0.minimumFractionDigits = newValue } }
}
open var maximumFractionDigits: Int {
get { _lock.withLock { $0.maximumFractionDigits } }
set { _lock.withLock { $0.maximumFractionDigits = newValue } }
}
open var minimum: NSNumber? {
get { _lock.withLock { $0.minimum } }
set { _lock.withLock { $0.minimum = newValue } }
}
open var maximum: NSNumber? {
get { _lock.withLock { $0.maximum } }
set { _lock.withLock { $0.maximum = newValue } }
}
open var currencyGroupingSeparator: String! {
get { _lock.withLock { $0.currencyGroupingSeparator } }
set { _lock.withLock { $0.currencyGroupingSeparator = newValue } }
}
open var isLenient: Bool {
get { _lock.withLock { $0.isLenient } }
set { _lock.withLock { $0.isLenient = newValue } }
}
open var usesSignificantDigits: Bool {
get { _lock.withLock { $0.usesSignificantDigits } }
set { _lock.withLock { $0.usesSignificantDigits = newValue } }
}
open var minimumSignificantDigits: Int {
get { _lock.withLock { $0.minimumSignificantDigits } }
set { _lock.withLock { $0.minimumSignificantDigits = newValue } }
}
open var maximumSignificantDigits: Int {
get { _lock.withLock { $0.maximumSignificantDigits } }
set { _lock.withLock { $0.maximumSignificantDigits = newValue } }
}
open var isPartialStringValidationEnabled: Bool {
get { _lock.withLock { $0.isPartialStringValidationEnabled } }
set { _lock.withLock { $0.isPartialStringValidationEnabled = newValue } }
}
open var hasThousandSeparators: Bool {
get { _lock.withLock { $0.hasThousandSeparators } }
set { _lock.withLock { $0.hasThousandSeparators = newValue } }
}
open var thousandSeparator: String! {
get { _lock.withLock { $0.thousandSeparator } }
set { _lock.withLock { $0.thousandSeparator = newValue } }
}
open var localizesFormat: Bool {
get { _lock.withLock { $0.localizesFormat } }
set { _lock.withLock { $0.localizesFormat = newValue } }
}
open var format: String {
get { _lock.withLock { $0.format } }
set { _lock.withLock { $0.format = newValue } }
}
open var positiveFormat: String! {
get { _lock.withLock { $0.positiveFormat } }
set { _lock.withLock { $0.positiveFormat = newValue } }
}
open var negativeFormat: String! {
get { _lock.withLock { $0.negativeFormat } }
set { _lock.withLock { $0.negativeFormat = newValue } }
}
open var roundingBehavior: NSDecimalNumberHandler {
get { _lock.withLock { $0.roundingBehavior } }
set { _lock.withLock { $0.roundingBehavior = newValue } }
}
}
|