Check if object is a dictionary

 Problem

I have an object and want to check if it's a Dictionary object.



 Recipe


// Initialize the dictionary

let dict = ["name":"John", "surname":"Doe"]

// Check if 'dict' is a Dictionary

if dict is Dictionary {
    print("Yes, it's a Dictionary")
}

				

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