Skip to content

Commit

Permalink
Enable NSLocale keyed archiving unit tests (#596)
Browse files Browse the repository at this point in the history
* Archive NSLocale identifier as NSString

* Override isEqual for NSLocale

* Uncomment NSLocale archiving test
  • Loading branch information
itaiferber authored and phausler committed Aug 25, 2016
1 parent 99493a4 commit 80e0f05
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Foundation/NSLocale.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ open class NSLocale: NSObject, NSCopying, NSSecureCoding {
return self
}

override open func isEqual(_ object: Any?) -> Bool {
guard let locale = object as? NSLocale else {
return false
}

return locale.localeIdentifier == localeIdentifier
}

open func encode(with aCoder: NSCoder) {
if aCoder.allowsKeyedCoding {
let identifier = CFLocaleGetIdentifier(self._cfObject)
let identifier = CFLocaleGetIdentifier(self._cfObject)._nsObject
aCoder.encode(identifier, forKey: "NS.identifier")
} else {
NSUnimplemented()
Expand Down
2 changes: 1 addition & 1 deletion TestFoundation/TestNSKeyedArchiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class TestNSKeyedArchiver : XCTestCase {
("test_archive_concrete_value", test_archive_concrete_value),
("test_archive_dictionary", test_archive_dictionary),
("test_archive_generic_objc", test_archive_generic_objc),
// ("test_archive_locale", test_archive_locale),
("test_archive_locale", test_archive_locale),
("test_archive_string", test_archive_string),
("test_archive_mutable_array", test_archive_mutable_array),
("test_archive_mutable_dictionary", test_archive_mutable_dictionary),
Expand Down

0 comments on commit 80e0f05

Please sign in to comment.