Auto-convert enum string values to Title Case?

Inferring from the default generated property list with every Xcode project, and documentation examples from Apple, each key entry is in title case and with spacing i.e. natural language.

However, I can't seem to find any conventional guidelines on how data is supposed to be entered in a plist. I ask because I am currently refactoring with enums to avoid potential miss-match complications, but as all enum cases must be written in camel case I have to add string associations, which can be quite verbose to look at.

If unchanged, string values are the same as their case name by default, and I was hoping there would be a quick way to simply conform to title case, but no such luck. However, I wonder now if I am supposed to leave spaces between words in a plist and this would be the the wrong anyway?

1 Like

I asked about this: Howto: DRY way to capitalized String rawValue enum case name?

But not about plist...

I've seen in Apple example they just add a var displayName: String or var name: String getter to return properly spelled out text name.

1 Like

Hi, thanks for the info!

I like the capitalized option, it's clean, easy and optional. I use title case without spacing inside my plist anyway, so I should be fine.

1 Like