I am working on an app which I plan to submit to App Store in 2 weeks. Now I have a headache with Array type.
I have the following API design in my app:
class SomeParser {
func getTranslations(_ locale: String) -> [TranslationUnit]? {
// Check if the locale units are already in a cache, if not build a new list
// and return the list
}
}
class MainVC {
func doTranslation() {
var list = parser.getTranslation("en")
// Modify some units in the list.
// How to put it back to cache?
}
}
Now the problem is that since Array is a value type, the modified list is isolated. The only way to reflect the changes into cache is put the modified list back to cache:
translationCache[locale] = modifiedList
But this is counter-intuitive and waste of performance.
Is there anyway to workaround this problem?