ios - loop specific keys in dictionary to get values -


i have associative array of workouts key workout name , values of array of exercises.

i have uitableview contain each workout name , exercises. problem getting exercises each workout , displaying in relating cell.

this code far:

var workout = [string : [string] ]()  workout["chest"] = ["bench press","dumb bell incline", "dumb bell flies", "flat dumb bell press"] workout["back"] = ["deadlift","lat pulldowns", "uni lateral rows", "dumb bell row"]  override func numberofsectionsintableview(tableview: uitableview) -> int {     // #warning incomplete implementation, return number of sections     return 1 }  override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {     var keys = [string]()     keys = array(workout.keys)     // #warning incomplete implementation, return number of rows     return keys.count }   override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {     let cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) as! workouttableviewcell      var keys = [string]()     keys = array(workout.keys)     cell.workoutnamelabel.text = keys[indexpath.row]      value in workout[cell.workoutnamelabel.text!]!{          print(value)      }      return cell } 

so in first cell have label workout name , label underneath list of exercises concatenated single string.

for example:

the workout name - "chest" exercises -bench press,dumb bell incline,dumb bell flies, "flat dumb bell press

here image help

are looking create string second label? this?

let workoutkey = keys[indexpath.row] cell.workoutdesclabel.text  workout[workoutkey]?.joinwithseparator(", ")`? 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -