Remove item from dictionary with key

 Problem

I have a Dictionary and want to delete an item with a specific key.



 Recipe


// Initialize the Dictionary
var dict = ["name": "John", "surname": "Doe"]
 
// Remove item with key 'name'

dict.removeValueForKey("name")
print(dict)
				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground