How to create and add values to Dictionary in swift

I want to create a Dictionary in swift with different type of data(array, string,dictionary)I am able to insert new data to a key but having difficulty in appending more values to them
here is the json for the dictionary

  "GenInfo": {
    "First Name":"Varun",
    "Last Name":"Naharia",
    "Phone No":"123456789"
  "LangInfo": ["Hindi","English","Urdu","French"],
        "Collage":"Dept. Of Comp. Sci. & Infor. University Of Kota",

I want to add these values to dictionary one by one like first GenInfo, then first language of LangInfo then EduInfo

  • iPhone/iPad Downloading and Playing Simultaneously
  • How do I draw a point using Core Graphics?
  • How can I tell whether an `NSManagedObject` has been deleted?
  • Parse BaaS iOS LoginFields in Swift - .value should be changed to?
  • Under iOS 7, how do I hide and show status bar on the fly (whenever I want to)
  • SQLite Order By places umlauts & speical chars at end
  • LangInfo
    Lang Info


    I Used dict["GenInfo"] = ["FirstName":first,"LastName":last,"Phone":phone] to add the GenInfo in the dic where first and last is the variable with value.

    EDIT #1
    var dict = Dictionary<String, Any>()

    Solutions Collect From Internet About “How to create and add values to Dictionary in swift”

    This is a known issue, apparently not fixed yet (see Is it possible to have a dictionary with a mutable array as the value in Swift)

    The workaround would be to create a new variable with your array and then assign it back:

        var dict = [String: AnyObject]()
        dict["GenInfo"] = ["FirstName":"first","LastName":"last","Phone":"phone"]
        dict["Language"] = ["langage1", "langage2"]
        if var languages = dict["Language"] as? [String] {
            dict["Language"] = languages