I'm relatively new to iOS development, and yet this is a problem I just keep coming back to. In the last app I made, a high-school textbook definition review app, I had a large amount of text that was never changed. As use of global variables is frowned upon, I looked to alternatives like Singletons (how these would be more elegant eludes me, feels redundant), prepareForSegue (solves the issue, but it feels like there must be a better way) and permanent storage (makes no sense as the data is never altered, but it provides a central repository). Naively, I picked the latter, implementing a plist, diminishing performance.
My interpretation of use of singleton for this problem (in case my problem stems from misunderstanding):
class Global {
let array = ["item1","item2",...,"item1042"]
}
Now I can access array
from other classes by Global.array
. My array is in fact a 3-dimensional array, however I don't see how that would change the issue (would have preferred to create a class, with many instances, but that felt like further complicating an issue simply for readability).
Aside from using coreData, which again seems like overkill, I'm at my wits end.
I want to use a single, unchanged array/dictionary throughout all my classes, preferably without copying it into every class.
What is the proper style to achieve this?
I apologise if this has already been answered (it seems to general not to have been), but whatever answers I found were either too complex for my level of understanding, or unhelpful.