ios - Cannot subscript a value of type 'String' with an index of type 'String' -
i want display of name on tableview cell stored in postfromfriends array when wrote code shown below give me error of " cannot subscript value of type 'string' index of type 'string' " on declaration of name constant. if can help.thanx
var postsfromfriends = [string]()
this array appending name.
override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecellwithidentifier("cell") as! friendstasktableviewcell if let name = postsfromfriends[indexpath.row]["name"] as? string { cell.name?.text = name } return cell }
you have declared postsfromfriends
array of string
, sounds want array of dictionary:
var postsfromfriends = [[string:string]]()
Comments
Post a Comment