Need help on Array and API design

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?

waste of performance.

How did you evaluate the "waste of performance"

You seem to have problem with arrays being value type. But that is a basic Swift design. You'd better just take this into account and not wish to fight the system. You will loose.

PS: I do not see a problem in the solution you designed. Wish you dood continuation.

Need help on Array and API design
 
 
Q