Avatar
omochimetaru 6/4/2019 2:26 PM
@propertyDelegate @dynamicMemberLookup public struct EnvironmentObject<BindableObjectType> : DynamicViewProperty where BindableObjectType : BindableObject { public var delegateValue: ObjectBinding<BindableObjectType>.Wrapper { get } } (edited)
2:26 PM
EnvironmentObjectのdelegateValueが ObjectBinding.Wrapperで
2:27 PM
@propertyDelegate public struct ObjectBinding<BindableObjectType> : DynamicViewProperty where BindableObjectType : BindableObject { /// A wrapper of the underlying `BindableObject` that can create `Binding`s to its properties /// using dynamic member lookup. @dynamicMemberLookup public struct Wrapper { /// Creates a `Binding` to a value semantic property of a reference type. /// /// If `Value` is not value semantic, the updating behavior for any views /// that make use of the resulting `Binding` is unspecified. public subscript<Subject>(dynamicMember keyPath: ReferenceWritableKeyPath<BindableObjectType, Subject>) -> Binding<Subject> { get } }
2:27 PM
ObjectBinding.Wrapperは dynamicMemberLookupだった
2:28 PM
dynamicMemberLookupの、アクセスできるプロパティを、 ReferenceWritableKeyPath<BindableObjectType, S> として
2:28 PM
もともとのオブジェクトの型のKeyPathに制限してる
2:28 PM
DMLにそんな機能があるのわかってなかった。単純にどんなメソッドでもいけちゃうのかと。
2:29 PM
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - apple/swift-evolution
2:29 PM
これか。見逃してた。
2:30 PM
実行はダイナミックだけど、プロパティアクセスはスタティック・・・