0

我需要将结构引用从一个视图控制器传递到另一个。这是我的代码的一部分:

//在 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]()

代码向我显示错误:

“无法将类型 '[CollectionViewController.ViewCell]' 的值分配给类型 '[CollectionViewController2.ViewCell2]'”。

但为什么?我该如何解决?

4

0 回答 0