ios - TableViewController numberOfRowsInSection section -


i have controller buttons , tableviewcontroller 10 arrays. each button has index, pass tableviewcontroller.

in tableviewcontroller code looks this:

override func tableview(_ tableview: uitableview, numberofrowsinsection section: int) -> int {      if buttonindex == 0 {         return array0.count     }     else if buttonindex == 1 {         return array1.count     }     else if buttonindex == 2 {         return array2.count     }     else if buttonindex == 3 {         return array3.count     }     else if buttonindex == 4 {         return array4.count     }     else if buttonindex == 5 {         return array5.count     }     else if buttonindex == 6 {         return array6.count     }     else if buttonindex == 7 {         return array6.count     }     else if buttonindex == 8 {         return array6.count     }      return array0.count } 

i want automatically define current index this:

override func tableview(_ tableview: uitableview, numberofrowsinsection section: int) -> int {         //return array(currentindex).count     } 

how it?

one way achieve want creating map, index key , array value.

so code should this:

override func tableview(_ tableview: uitableview, numberofrowsinsection section: int) -> int {     return indicesarray[index].count } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -