Swift: Cannot subscript a value of type 'Array' -


i have started learning swift ios development. encountering problem not able solve. can please tell doing wrong? image below contains screenshot of 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 array of 7 empty arrays     var tabledata:array = [[string]] (count: 7,repeatedvalue:[])     override func viewdidload() {         super.viewdidload()         // additional setup after loading view, typically nib.     }     override func didreceivememorywarning() {         super.didreceivememorywarning()         // dispose of resources can 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 value of type 'array'             textfield.text = ""             tableview.reloaddata()         }     } } 

screenshot

thanks!

i remembered ran problem few times when went old projects bit outdated. me fix change, in example,

var tabledata:array = [[string]]

to

var tabledata = [[string]] 

Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -