1

When I am initializing it, doStuff() is not called, can anybody let me why it's happening and how can I call this while initialization.

For now, doStuff() is called only when i am changing the value of flightTripTypeEnum

var flightTripTypeEnum: FlightJourneyTypeEnum = .OneWayTrip {
                didSet{
                    doStuff()
                }
            }
Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
  • did set is fired when the value changes, not when its initialised with a default value. This is expected behaviour – Scriptable Jul 30 '21 at 09:05
  • 2
    Because thats how Swift works. It didSet were called during initialization then it would greately complicate things, e.g. you would have nonoptional variables without assigned values. – Sulthan Jul 30 '21 at 09:06

0 Answers0