ios – The way to make a persistent record of choices in Swift?

I am engaged on an app associated to a TTRPG (Pathfinder 2e, particularly, in case you needed to know). That is my first foray into Swift and iOS improvement, and I am struggling to grasp the suitable option to do what I need.
In a TTRPG, you might have your “Means Scores” – Power (STR), Dexterity (Dex), Structure (CON), Knowledge (WIS), Intelligence (INT), and Charisma (CON).
I might like to have the ability to make a struct (I believe? Possibly this needs to be a category?) that appears one thing like this:
struct AbilityScores {
var shortName: String //i.e. STR
var longName: String //i.e. Power
var description: String //i.e. "Power is used for XYZ and PDQ"
};
AbilityScores
will all the time have precisely these six values. My instincts inform me that I needs to be utilizing an enum
for this, however I am not precisely positive how you can make the enum perform appropriately.
I can do one thing like
struct abilityScore {
var brief: String
var lengthy: String
var description: String
init (brief: String, lengthy: String, desc: String){
self.brief = brief
self.lengthy = lengthy
self.description = desc
}
}
enum AbilityScores {
case STR
case DEX
case CON
case INT
case WIS
case CHA
func GetAbilityScore() -> abilityScore {
swap self {
case .STR:
return abilityScore(brief: "STR", lengthy: "Power", desc: "Power Description")
case .DEX:
return abilityScore(brief: "DEX", lengthy: "Dexterity", desc: "Dex Description")
case .CON:
return abilityScore(brief: "CON", lengthy: "Structure", desc: "Con Description")
case .INT:
return abilityScore(brief: "INT", lengthy: "Intelligence", desc: "Int Description")
case .WIS:
return abilityScore(brief: "WIS", lengthy: "Knowledge", desc: "Knowledge Description")
case .CHA:
return abilityScore(brief: "CHA", lengthy: "Charisma", desc: "CHA description")
};
}
}
Then, for instance, I can have one thing that appears like this in one other spot:
struct Background {
var identify: String
var description: String
var allowedAbilityBoosts: [abilityScore] = [AbilityScores.CON.GetAbilityScore(), AbilityScores.DEX.GetAbilityScore()]
}
and simply name GetAbilityScore()
wherever I need it.
Is that this the proper method?
What a few situation (like for Background) the place as an alternative of getting 6 gadgets, I’ve up to a few hundred? Is there a greater option to instantiate the record of all of the gadgets? I am pleased to learn documentation on this, however I do not know the place to even begin.
Wouldn’t it be acceptable to make use of an inner SQLite database (if that is even a factor in iOS improvement) to retailer the information? Or am I going to be caught in enum purgatory?
Credit: www.ismmailgsm.com