How to access userDefaults using a function

I have a userDefault using Appstorage and would like to have a function access that value to use in a switch. What would be the best approach to accomplish this?

How to access userDefaults using a function
 
 
Q