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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -