Initialising empty arrays of dictionaries in Swift

后端 未结 6 1289
北恋
北恋 2021-01-30 02:18

I\'m trying to wrap my head around initialising empty arrays in Swift.

For an array of strings it\'s pretty straight forward :

var myStringArray: String         


        
6条回答
  •  长发绾君心
    2021-01-30 02:54

    You need to give types to the dictionaries:

    var myNewDictArray: [Dictionary] = []
    

    or

    var myNewDictArray = [Dictionary]()
    

    Edit: You can also use the shorter syntax:

    var myNewDictArray: [[String:Int]] = []
    

    or

    var myNewDictArray = [[String:Int]]()
    

提交回复
热议问题