Skip to content

Commit 0592ccf

Browse files
committed
Fix NSKeyedUnarchiver.decodeBool(forKey:) and add test to TestNSPredicate.test_NSCoding()
1 parent b19da15 commit 0592ccf

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Foundation/NSKeyedUnarchiver.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,10 @@ open class NSKeyedUnarchiver : NSCoder {
683683
}
684684

685685
open override func decodeBool(forKey key: String) -> Bool {
686-
guard let result : NSNumber = _decodeValue(forKey: key) else {
686+
guard let result : Bool = _decodeValue(forKey: key) else {
687687
return false
688688
}
689-
return result.boolValue
689+
return result
690690
}
691691

692692
open override func decodeInt32(forKey key: String) -> Int32 {

TestFoundation/TestNSPredicate.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ class TestNSPredicate: XCTestCase {
101101
let predicateA = NSPredicate(value: true)
102102
let predicateB = NSKeyedUnarchiver.unarchiveObject(with: NSKeyedArchiver.archivedData(withRootObject: predicateA)) as! NSPredicate
103103
XCTAssertEqual(predicateA, predicateB, "Archived then unarchived uuid must be equal.")
104+
let predicateC = NSPredicate(value: false)
105+
let predicateD = NSKeyedUnarchiver.unarchiveObject(with: NSKeyedArchiver.archivedData(withRootObject: predicateC)) as! NSPredicate
106+
XCTAssertEqual(predicateC, predicateD, "Archived then unarchived uuid must be equal.")
104107
}
105108

106109
func test_copy() {

0 commit comments

Comments
 (0)