5
하나만 사용하는 대신 여러 대의 대리자를 추가하는 것은 매우 일반적인 작업입니다.NSHashTable을 사용하여 Swift에서 Observer 패턴 구현 3
Using 'ObserverProtocol' as a concrete type conforming to protocol 'AnyObject' is not supported
이 약한 대표의 집합을 만들 수도 가능 : 우리가 AnyObject
프로토콜을 준수하는 ObserverProtocol
을 강제로하려고하면
protocol ObserverProtocol
{
...
}
class BroadcasterClass
{
// Error: Type 'ObserverProtocol' does not conform to protocol 'AnyObject'
private var _observers = NSHashTable<ObserverProtocol>.weakObjects()
}
것은, 우리가 또 다른 오류가 발생합니다 : 우리는 프로토콜과 클래스가 있다고 가정 스위프트 3.0 에서요?