I have app delegate which is a single point in app. Also I've created ApplicationManager class which is a part of app delegate now.
so what I want to achieve is to protect my code from other developers to be used in a wrong way.
So let's say my ApplicationManager looks like this:
class ApplicationManager {
var api: API?
static func instance() -> ApplicationManager {
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
fatalError()
}
return appDelegate.applicationManager
}
}
I want to make sure that used will use ApplicationManager via:
let am = ApplicationManager.instance() but not like this am = ApplicationManager() which will create one more manager which I don't want.
is there a way to show build time error? or drop some message? or crash in crash in case there are more that one ApplicationManager in app =)