Grouping Array Elements With Dictionary in Swift Swift 5 introduced a new initializer for Dictionary, which allows us to create a dictionary of grouped elements from an input array. Here, Lee Kah Seng demonstrates how we can use this initializer to group array elements based on a custom property of the array element type. Posted on July 3, 2020 #array #dictionary
Key difference between Dictionary and NSDictionary Jeff Johnson points out an interesting difference between Swift Dictionary and NSDictionary. The difference relates to how Swift implements String equality as Unicode canonical equivalence, and as Jeff points out, this could cause problems if you save and load dictionaries from user defaults. Posted on December 12, 2017 #dictionary
Dictionary and Set Improvements in Swift 4.0 Swift 4 added a lot of really awesome Dictionary and Set APIs. Operations like grouping, filtering, and transforming values are easier than ever, and can be performed in a single step. In this post on the official Swift blog, Nate Cook explores these new APIs. It’s also worth noting that most of the changes mentioned are available in Swift 3.2, so even if you have not yet moved to Swift 4, there is something here for you. Posted on October 10, 2017 #swift 4 #dictionary #set
The startling uniquing of Swift 4 dictionaries Another great post from Erica Sadun. Here Erica shows us how we can use the new uniquing feature which has been added to the Dictionary type in Swift 4. This feature allows us to create a Dictionary of unique keys, while applying a function to each key's value each time a duplicate key is added. In one example, Erica uses this to find out which word appears the most in a large String. Posted on June 27, 2017 #swift 4 #dictionary