Swift: use of 'self' in method call before super.init initializes self compile error Swift: use of 'self' in method call before super.init initializes self compile error ios ios

Swift: use of 'self' in method call before super.init initializes self compile error


Just place it under super.init().

The object needs to be initialized first by the super class and then you can do your custom initialization.

override init() {    super.init()    setupAudioSession()}


If you are working with the MVVM pattern, and you really need to call to some function before the super.init, you can always move that function to the ViewModel and call it from there. Just inject the viewModel as an injected dependency.


matomo