0
Wenn Sie diesen Code auf Xcode 9.1 mit der Optimierungsstufe Fast, whole Module Optimization
ausführen, stürzt er ab. Wenn die Optimierungsstufe auf None
eingestellt ist, ist alles in Ordnung.Swift 4 Fehler bei Release-Konfiguration
Hat jemand eine Idee von dem Problem?
protocol FooProtocol {
func foo()
}
class FooProtocolImplementation : NSObject, FooProtocol {
func foo() {}
}
var set: Set<AnyHashable> = []
_ = set.insert(FooProtocolImplementation())
let array = set.flatMap { $0 as? FooProtocol } // filtering out nils
_ = array[0] // # error (EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
Was ist, wenn Sie erben nicht von 'NSObject'? – LShi
Es funktioniert nicht –
Was würde passieren, wenn Sie 'FooProtocol' als Klassenprotokoll festlegen:' Protokoll FooProtocol: class'? Und wenn Sie mehr Details zur Verfügung stellen können, wie in welcher Zeile es abstürzt. – Ivan