0
ReferenceWritaleKeyPath
を使用してプロパティを読み取ると、コンパイラのセグメント化エラーが発生しています。`ReferenceWritableKeyPath 'を使用したSwiftコンパイラのセグメント化エラー
私は、2つの変数のバインドを簡素化するヘルパーを設定しています。 help from OOPer私は基本的なバインディングを取得しましたが、バインディングを実行する前に値が異なることを確認するために以下に示すコードを変更すると、セグメント化エラーが発生します。
protocol Bindable: class {
var observers: [NSKeyValueObservation] {get set}
}
extension Bindable {
func bind<Value>(to targetKeyPath: ReferenceWritableKeyPath<Self, Value>, from sourceKeyPath: KeyPath<Self, Value>)
where Self: NSObject {
self.observers.append(self.observe(sourceKeyPath, options: [.initial, .new]) {object, change in
// FAILS: compiler failed due to signal: Segmentation fault: 11
if(self[keyPath:targetKeyPath] != change.newValue) {
self[keyPath: targetKeyPath] = change.newValue!
}
})
}
}
私はを試しましたが、Stringはプロトコルまたはクラスではありませんでした。 Equatableは私が必要としたものです。提案されたセグメンテーション違反のバグを提出しました:SR-5375 –