I understand that there is a difference in how elements are stored in a NSSet and a NSDictionary, https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Collections/Collections.html
But from a development point of view, when should I use NSSet vs NSDictionary? The time complexity for both is O(1)
Edit: I came across the question - Remove duplicates from an array. One solution stored the elements in a NSDictionary to remove duplicates, the other solution stored the elements in a NSSet.
I was wondering which would be a better approach
NSSet and NSDictionary are very different. NSSet is a set of elements meanwhile NSDictionary keeps a list of key-value pairs, so you can access the Value directly when you have the Key. It's more meaningful to compare NSSet to NSArray than to NSDictionary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With