You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
finalclassCounter{varvalue=0}protocolMyResolver:Resolver{
// A MyResolver instance always returns the same instance of Counter.
func provideCounter()->Shared<Counter>}
// Generated code
extensionMyResolver{func resolveCounter()->Counter{finalclassScope{
// NOTE: WeakDictionary doesn't present in standard library.
staticvarsharedInstances=[:]asWeakDictionary<MyResolver,Counter>}
// Return shared instance associated with MyResolver instance if it presents.
iflet sharedInstance =Scope.sharedInstances[self]{return associatedObject
}
// If shared instance is not found, call provider method and save returned instance as a shared instance.
letsharedInstance=provideCounter()Scope.sharedInstances[self]= sharedInstance
return sharedInstance
}}
The text was updated successfully, but these errors were encountered:
Rough sketch:
The text was updated successfully, but these errors were encountered: