How can I use a Mutable Strongly Type array in Swift? I am adding ShoppingList object to an Array like this:
func getAllShoppingLists() -> Array<ShoppingList> {
let shoppingLists = Array<ShoppingList>()
db.open()
let results = try! db.executeQuery("SELECT * from ShoppingLists", values: nil)
defer {
db.close()
}
while(results.next()) {
let shoppingList = ShoppingList()
shoppingList.title = results.stringForColumn("title")
shoppingLists.append(shoppingList)
}
return shoppingLists
}
The problem comes that the shoppingLists is declared as "let". If I change to "var" it works fine. The reason of course is that I am changing the number of items in the array. Is this the best way?