Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
拡張機能の計算されたプロパティがゲッターとセッターの両方を持つことは可能ですか? Apple のガイドではそれについて言及されておらず、私が見た唯一の例は、拡張機能で読み取り専用の計算されたプロパティのみを示しています。
これは機能します:
extension Bool { public var integerValue: Int { get { return true ? 1 : 0 } set { self = (newValue > 0) ? true : false } } }
そうです。