Hello!
I have a problem to make a prepareforsegue into UIcollectionview /CoreData.
I need that the “cell” in View FilmList with tap go to open View of Film Detail.
I use it for tableview and I don’t have a problem but with Uicollectonview, I have any problems.
I hope you can help me
This is the code
VIEW FILMLIST
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// controlliamo che il nome del segue corrisponda alla parola dettaglio
if segue.identifier == "VediScheda" {
// controlliamo quale cella è stata toccata
if let indexPath = self.collectionView.indexPathsForSelectedItems {
// estraiamo dal segue il DetailController
let controller = segue.destination as! SchedaAnime
let cell = sender as! UICollectionViewCell
let indexPath = self.collectionView!.indexPath(for: cell)
let selectedData = taskArray[(indexPath?.row)!]
// taskarrayscheda is the variable that will be sent
controller.taskArrayScheda = selectedData
}
}
}
VIEW DETAILS
import UIKit
import CoreData
// Global Variables and Constants
let appDelegateScheda = UIApplication.shared.delegate as? AppDelegate
class SchedaAnime: UIViewController, UITextFieldDelegate {
// Varables
var taskArrayScheda : NewAnime?
override func viewDidLoad() {
super.viewDidLoad()
if(self.taskArrayScheda != nil) {
let schedaOk = taskArrayScheda
titoloScheda.text = taskArrayScheda?.titolo
} else { print("error array vuoto") }
}