Да конечно
Вот тут я получаю данные, записываю и передаю их в массив:
class PDD_Categories: ExpandingTableViewController {
@IBOutlet weak var titleImageViewXConstraint: NSLayoutConstraint!
@IBOutlet weak var titleImageView: UIImageView!
fileprivate var scrollOffsetY: CGFloat = 0
var pddCategories = [PDDRulesEntity]()
var pddCategoriesDetail = [PDDDetailScreens]()
override func viewDidLoad() {
super.viewDidLoad()
tableView.tableFooterView = UIView(frame: CGRect.zero)
//MARK: - fetch Request
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {return}
let managedContext = appDelegate.persistentContainer.viewContext
let fetchRequest1:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest(entityName: "PDDDetailScreens")
do {
pddCategoriesDetail = try managedContext.fetch(fetchRequest1) as! [PDDDetailScreens]
} catch let error as NSError {
print("Fetch error \(error)")
}
self.tableView.reloadData()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return pddCategories.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! PDD_CategoriesCell
cell.nameCategories.text = pddCategories[indexPath.row].titlePDD
return cell
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showDeteilPDDScreen" {
if let indexPath = tableView.indexPathForSelectedRow {
let destinationDetailPDDTVC : DetailPDDTVC = segue.destination as! DetailPDDTVC
destinationDetailPDDTVC.headerPDDScreenLabel = pddCategories[indexPath.row].titlePDD!
destinationDetailPDDTVC.titleDetailPddScreen = [pddCategoriesDetail[indexPath.row].titleGeneralProvisions!]
destinationDetailPDDTVC.textDetailPddScreen = [pddCategoriesDetail[indexPath.row].textGeneralProvisions!]
destinationDetailPDDTVC.imageDetailPddScreen = [pddCategoriesDetail[indexPath.row].imageGeneralProvisions!]
}
}
}
}
Вот тут суда я должен передать в 3 массива:
class DetailPDDTVC: UITableViewController {
@IBOutlet weak var headerPDDScreen: UILabel!
var headerPDDScreenLabel = ""
var titleDetailPddScreen = [String]()
var textDetailPddScreen = [String]()
var imageDetailPddScreen = [NSData]()
override func viewDidLoad() {
super.viewDidLoad()
headerPDDScreen.text = headerPDDScreenLabel
tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.estimatedRowHeight = 70
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return titleDetailPddScreen.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! DetailPDDTVCell
cell.titleDetailPddScreen.text = titleDetailPddScreen[indexPath.row]
cell.textDetailPddScreen.text = textDetailPddScreen[indexPath.row]
cell.imageDetailPddScreen.image = UIImage(data: imageDetailPddScreen[indexPath.row] as! Data)
return cell
}
}