Skip to content

Commit f24b4d9

Browse files
committed
Merge pull request #49 from KaiCode2/DictionaryIsEqual
Implemented isEqualToDictionary
2 parents 5f474bb + 319020a commit f24b4d9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Foundation/NSDictionary.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,19 @@ public class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCodin
278278
public func descriptionWithLocale(locale: AnyObject?, indent level: Int) -> String { NSUnimplemented() }
279279

280280
public func isEqualToDictionary(otherDictionary: [NSObject : AnyObject]) -> Bool {
281-
NSUnimplemented()
281+
if count != otherDictionary.count {
282+
return false
283+
}
284+
285+
for key in keyEnumerator() {
286+
if otherDictionary[key] == nil {
287+
return false
288+
} else if otherDictionary[key] != objectForKey(key) {
289+
return false
290+
}
291+
}
292+
293+
return true
282294
}
283295

284296
public struct Generator : GeneratorType {

0 commit comments

Comments
 (0)