In Objective-C we could have different initializers that did different things and took no arguments.
- (instancetype) initForSomethingSpecific;
- (instancetype) initWithDefaultSettings;
So you could call them as
[[MyClass alloc] initForSomethingSpecific];
[[MyClass alloc] initWithDefaultSettings];
These type of initializers get translated in Swift as
init(forSomethingSpecific: ())
init(defaultSettings: ())
so they can be called as
MyClass(forSomethingSpecific: ())
MyClass(defaultSettings: ())
but this doesn't look very swifty.
Is there a correct way to do this in a Swift-only environment? Are factory methods preferred?
Thank you.