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
A little bit of a work around needs to be made In order to keep the model type-safe:
extensionModel{varentitiesByType:[String:[Identifier]]=[:]func store <T>(_ value:T,...)->Identifier{letidentifier= // make new identifier
entitiesByType.safelyAppend(value, forKey:"\(T.self)")return identifier
}func retrieve <T>(_ identifier:Identifier)->T{returnentities["\(T.self)"]as![T]}}
The text was updated successfully, but these errors were encountered:
The currently solution uses the String key. This is problematic for two reasons: with thousands or millions of hits, the creation of strings for the types is quite expensive. Furthermore, this doesn't actually preserve type information.
Instead, it may be better to implement Model as a protocol. Concrete implementations of Model-conforming types could extend the specific types they can store while retaining type information.
A little bit of a work around needs to be made In order to keep the model type-safe:
The text was updated successfully, but these errors were encountered: