-2

i'am downloading a data with json. and i show them in tableview. i want to send two array to detail table view and show them. but i can give datas on first table view but i canno show details in second table view. i cannot send arrays to detail table view.

 ///for showing next detailed screen with the downloaded info
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {        
let vc = self.storyboard?.instantiateViewController(withIdentifier: "detailTimetableViewController") as! detailTimetableViewController
        vc.classfArr = [classArray[indexPath.row]] //problem is here i think
        vc.daysArr = [daysArray[indexPath.row]]
        vc.lessonsArr = [lessonsArray[indexPath.row]]
        self.navigationController?.pushViewController(vc, animated: true)
    }

i've put breakpoint on didSelectRowAt. " vc.classfArr = [classArray[indexPath.row]]" line has a problem. app fail here. could you help me please?

i want to do this genarally; i want to show classes' timetable in first tableview and show timetables detail in second tableview. days must be section in second tableview.

C. Sayin
  • 1
  • 7
  • 1
    Possible duplicate of [How do you pass data between view controllers in Swift?](http://stackoverflow.com/questions/25215476/how-do-you-pass-data-between-view-controllers-in-swift) – Rob Jan 27 '17 at 15:10

1 Answers1

0

You're sending an individual singular object from each array rather than the array itself.

fixed:

///for showing next detailed screen with the downloaded info
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {        
let vc = self.storyboard?.instantiateViewController(withIdentifier: "detailTimetableViewController") as! detailTimetableViewController
        vc.classfArr = classArray
        vc.daysArr = daysArray
        vc.lessonsArr = lessonsArray
        self.navigationController?.pushViewController(vc, animated: true)
    }
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
torinpitchers
  • 1,282
  • 7
  • 13