Objective-C has a peculiar, but very helpful ability to make an initializer return a different instance than the one the initializer is being called on. You can read about that here.
It's great for things like class clusters, but even for things as simple as ensuring specific instances are returned based on specific conditions (i.e. newing up an Account class with an account number will always return the same instance of the Account class for that number.)
However, in our app, we're using Swift but I don't see any such provisions in this language. Is there such a thing?
Normally we'd simply create a class method to return the instance we're interested in, but while we own the class in question, we do not own the calling code which uses the standard initializer syntax. e.g.
let foo = OurClass()
We want to control which instance is handed back to them based on some external conditions (omitted for clarity here.)
So does Swift have any such mechanisms?