FactoryInitializable
public protocol FactoryInitializable : Sendable
Classes whose initializers actually create derived classes
-
The type of the least-derived class declared to be FactoryInitializable.
Warning
Do not define this in your FactoryInitializable type!Declaration
Swift
associatedtype FactoryBase : AnyObject, FactoryInitializable = Self
-
init(unsafelyAliasing:Extension method) Optimally “creates” an instance that is just another reference to
me.Requires
me is Self.Taking
FactoryBaseas a parameter prevents, at compile-time, the category of bugs wheremeis not derived from the least-derived ancestor ofSelfconforming toFactoryInitializable.However, there are still ways
memight not be derived fromSelf. If you have factory initializers at more than one level of your class hierarchy and you can’t control exactly what is passed here, useinit(aliasing:)instead.Declaration
Swift
public init(unsafelyAliasing me: FactoryBase) -
init(aliasing:Extension method) Safely “creates” an instance that is just another reference to
me.Requires
me is Self.Declaration
Swift
public init(aliasing me: FactoryBase)
View on GitHub