就像下面顯示的代碼一樣,為什么 swift 不允許分配只讀物件的屬性?只讀物件“localVc”具有設定寫入屬性“refreshGesture”。
public protocol HVSHomeVideoChildProtocol {
var refreshGesture: UIPanGestureRecognizer! {get set}
}
class HVSHomeLocalVideoController: HVSHomeVideoChildProtocol {
public var refreshGesture: UIPanGestureRecognizer!
}
typealias HVSHomeVideoController = (UIViewController & HVSHomeVideoChildProtocol)
@objc(HSAVideoHomeViewController)
class HSAVideoHomeViewController: UIViewController {
var refreshGesture: UIPanGestureRecognizer!
let singleLocalVc = HVSHomeLocalVideoController.init()
var localVc: HVSHomeVideoController {
return singleLocalVc
}
public override func viewDidLoad() {
super.viewDidLoad()
refreshGesture = UIPanGestureRecognizer.init(target: self, action: #selector(refreshGestureAction(sender:)))
localVc.refreshGesture = refreshGesture
}
}
uj5u.com熱心網友回復:
改變
public protocol HVSHomeVideoChildProtocol {
var refreshGesture: UIPanGestureRecognizer! {get set}
}
到
public protocol HVSHomeVideoChildProtocol : AnyObject {
var refreshGesture: UIPanGestureRecognizer! {get set}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/313637.html
