Cannot assign value of type '[CollectionViewController.ViewCell]' to type '[CollectionViewController 2.ViewCell2]'

58 views Asked by At

I need to pass a structure reference from one view controller to another. Here is my code's part:

//In CollectionViewController.swift

 struct ViewCell{
    var lbl : String
    var details: String
 }
 var cellDetails = [ViewCell]()
 //In a action method of button tapped
 let vc = CollectionViewController2.init(nibName: 
           "CollectionViewController2", bundle: nil)
 vc.cellDetails2 = self.cellDetails
 self.navigationController?.pushViewController(vc, animated: true)
 //In CollectionViewController2.swift ---**                
struct ViewCell2{
    var lbl : String
    var details: String
}
var cellDetails2 = [ViewCell2]()

code shows me error:

"Cannot assign value of type '[CollectionViewController.ViewCell]' to type '[CollectionViewController2.ViewCell2]'".

But why? How can I resolve it?

0

There are 0 answers