From b488e6cd92ea49b1b5615e9762230c3ba9bc594e Mon Sep 17 00:00:00 2001 From: Kai Aldag Date: Sat, 5 Dec 2015 20:55:28 -0800 Subject: [PATCH 1/2] Implemented isEqualToDictionary --- Foundation/NSDictionary.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Foundation/NSDictionary.swift b/Foundation/NSDictionary.swift index d9520ad108..d0e68682ca 100644 --- a/Foundation/NSDictionary.swift +++ b/Foundation/NSDictionary.swift @@ -278,7 +278,19 @@ public class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCodin public func descriptionWithLocale(locale: AnyObject?, indent level: Int) -> String { NSUnimplemented() } public func isEqualToDictionary(otherDictionary: [NSObject : AnyObject]) -> Bool { - NSUnimplemented() + if count != otherDictionary.count { + return false + } + + for (key, value) in _storage { + if otherDictionary[key] == nil { + return false + } else if otherDictionary[key] != value { + return false + } + } + + return true } public struct Generator : GeneratorType { From 319020ac8976336bc893944545ea2924ba08479d Mon Sep 17 00:00:00 2001 From: Kai Aldag Date: Sat, 5 Dec 2015 23:21:20 -0800 Subject: [PATCH 2/2] removed the use of _storage for keyEnumerator --- Foundation/NSDictionary.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Foundation/NSDictionary.swift b/Foundation/NSDictionary.swift index d0e68682ca..fdffcb9ae7 100644 --- a/Foundation/NSDictionary.swift +++ b/Foundation/NSDictionary.swift @@ -282,10 +282,10 @@ public class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCodin return false } - for (key, value) in _storage { + for key in keyEnumerator() { if otherDictionary[key] == nil { return false - } else if otherDictionary[key] != value { + } else if otherDictionary[key] != objectForKey(key) { return false } }