File tree Expand file tree Collapse file tree 1 file changed +25
-26
lines changed Expand file tree Collapse file tree 1 file changed +25
-26
lines changed Original file line number Diff line number Diff line change @@ -609,35 +609,34 @@ open class NSNumber : NSValue {
609
609
}
610
610
611
611
open override func encode( with aCoder: NSCoder ) {
612
- if !aCoder. allowsKeyedCoding {
613
- NSUnimplemented ( )
612
+ guard aCoder. allowsKeyedCoding else {
613
+ preconditionFailure ( " Unkeyed coding is unsupported. " )
614
+ }
615
+ if let keyedCoder = aCoder as? NSKeyedArchiver {
616
+ keyedCoder. _encodePropertyList ( self )
614
617
} else {
615
- if let keyedCoder = aCoder as? NSKeyedArchiver {
616
- keyedCoder . _encodePropertyList ( self )
618
+ if CFGetTypeID ( self ) == CFBooleanGetTypeID ( ) {
619
+ aCoder . encode ( boolValue , forKey : " NS.boolval " )
617
620
} else {
618
- if CFGetTypeID ( self ) == CFBooleanGetTypeID ( ) {
621
+ switch objCType. pointee {
622
+ case 0x42 :
619
623
aCoder. encode ( boolValue, forKey: " NS.boolval " )
620
- } else {
621
- switch objCType. pointee {
622
- case 0x42 :
623
- aCoder. encode ( boolValue, forKey: " NS.boolval " )
624
- break
625
- case 0x63 : fallthrough
626
- case 0x43 : fallthrough
627
- case 0x73 : fallthrough
628
- case 0x53 : fallthrough
629
- case 0x69 : fallthrough
630
- case 0x49 : fallthrough
631
- case 0x6C : fallthrough
632
- case 0x4C : fallthrough
633
- case 0x71 : fallthrough
634
- case 0x51 :
635
- aCoder. encode ( int64Value, forKey: " NS.intval " )
636
- case 0x66 : fallthrough
637
- case 0x64 :
638
- aCoder. encode ( doubleValue, forKey: " NS.dblval " )
639
- default : break
640
- }
624
+ break
625
+ case 0x63 : fallthrough
626
+ case 0x43 : fallthrough
627
+ case 0x73 : fallthrough
628
+ case 0x53 : fallthrough
629
+ case 0x69 : fallthrough
630
+ case 0x49 : fallthrough
631
+ case 0x6C : fallthrough
632
+ case 0x4C : fallthrough
633
+ case 0x71 : fallthrough
634
+ case 0x51 :
635
+ aCoder. encode ( int64Value, forKey: " NS.intval " )
636
+ case 0x66 : fallthrough
637
+ case 0x64 :
638
+ aCoder. encode ( doubleValue, forKey: " NS.dblval " )
639
+ default : break
641
640
}
642
641
}
643
642
}
You can’t perform that action at this time.
0 commit comments