1
私は代理プロトコルに準拠したジェネリッククラスを持っています。私はプロトコルのメソッドでself
を渡すことができるようにしたいが、私はどのように把握することはできません。セルフスクロール汎用プロトコル関数
protocol BodyPartManagerDelegate: class {
func doit(manager: BodyPartManager<Any>)
}
class BodyPartManager<Part> {
weak var delegate: BodyPartManagerDelegate?
var parts: [Part] = []
}
class Neck {}
class NeckManager: BodyPartManager<Neck> {
func doingit() {
delegate?.doit(manager: self)
}
}
上記のコードでは、protocol 'BodyPartManagerDelegate' can only be used as a generic constraint because it has Self or associated type requirements
が得られます。このプロトコルのメソッドでself
にアクセスするにはどうすればよいですか?
チェック、トピックでは、任意のようなプロトコルのパラメータを作れば – Andrea
かなり広いとは何か?私はこのように意味する:func doit(マネージャー:Any?)。その後、それをアンラップすることができます。 – Woof