How do you implement a setter without getter in Swift? I need to call the method when the value is set:
var selectedIndex : Int{ set{ selectItemAtIndex(newValue) } }
but in Swift you need to use both getter and setter, not just one.
You can use the observer property didSet. This will be called immediately after setting the value.
didSet
var selectedIndex: Int { didSet { selectItemAtIndex(selectedIndex) } }
Source: https://habr.com/ru/post/1544698/More articles:Web API authorization using ClientId and ClientSecret - asp.netstandard specialization Either where the types Left and Right are the same - typesType error in Monad definition - haskellEclipse stops working, freezes and stops responding to any actions - javaHow can I catch errors when connecting to / from javas stdin / stdout - javaIs a copy constructor created by default? - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1544700/adding-subtotals-to-an-ssrs-report-tablix&usg=ALkJrhjmVHkFiN3nDeVZdUOaR1Mq8kV0EQHow to split a python string into newline characters - pythonHow can I get a set of Enums except one using Linq? - c #How to subclass a UIViewController in Swift? - iosAll Articles