I have just started learning swift ios development. I am encountering this problem which I am not able to solve. Can someone please tell what I am doing wrong? The image below contains screenshot of the error.
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var dayPicker: UIPickerView!
@IBOutlet weak var addButton: UIButton!
@IBOutlet weak var textField: UITextField!
let days = ["Sunday","Monday","Tuesday","Thursday","Friday","Saturday"]
// creates an array of 7 empty arrays
var tableData:Array = [[String]] (count: 7,repeatedValue:[])
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func addObjectToTable(sender: AnyObject) {
if(textField.text != "")
{
print (days[dayPicker.selectedRowInComponent(0)])
print (textField.text!)
tableData[dayPicker.selectedRowInComponent(0)].append(textField.text!); // Error: Cannot subscript a value of type 'Array'
textField.text = ""
tableView.reloadData()
}
}
}
Thanks!

stringto an array of arrays... you can append an array to the array of arrays, but you cannot append a string to an array that holds arrays.