File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ public class NSDecimalNumber : NSNumber {
55
55
NSRequiresConcreteImplementation ( )
56
56
}
57
57
58
- public func descriptionWithLocale( locale: AnyObject ? ) -> String { NSUnimplemented ( ) }
58
+ public override func descriptionWithLocale( locale: AnyObject ? ) -> String { NSUnimplemented ( ) }
59
59
60
60
// TODO: "declarations from extensions cannot be overridden yet"
61
61
// Although it's not clear we actually need to redeclare this here when the extension adds it to the superclass of this class
Original file line number Diff line number Diff line change @@ -434,6 +434,10 @@ public class NSNumber : NSValue {
434
434
return val
435
435
}
436
436
437
+ public var stringValue : String {
438
+ return descriptionWithLocale ( nil )
439
+ }
440
+
437
441
/// Create an instance initialized to `value`.
438
442
public required convenience init ( integerLiteral value: Int ) {
439
443
self . init ( integer: value)
@@ -452,6 +456,12 @@ public class NSNumber : NSValue {
452
456
public func compare( otherNumber: NSNumber ) -> NSComparisonResult {
453
457
return . _fromCF( CFNumberCompare ( _cfObject, otherNumber. _cfObject, nil ) )
454
458
}
459
+
460
+ public func descriptionWithLocale( locale: AnyObject ? ) -> String {
461
+ guard let aLocale = locale else { return description }
462
+ let formatter = CFNumberFormatterCreate ( nil , ( aLocale as! NSLocale ) . _cfObject, kCFNumberFormatterDecimalStyle)
463
+ return CFNumberFormatterCreateStringWithNumber ( nil , formatter, self . _cfObject) . _swiftObject
464
+ }
455
465
456
466
override public var _cfTypeID : CFTypeID {
457
467
return CFNumberGetTypeID ( )
You can’t perform that action at this time.
0 commit comments