Get settings through a button action
Posted
by Russ Knudsen
on Stack Overflow
See other posts from Stack Overflow
or by Russ Knudsen
Published on 2010-05-11T21:16:08Z
Indexed on
2010/05/12
0:04 UTC
Read the original article
Hit count: 240
nsuserdefaults
|cocoa
I am looking for a way to access user settings (I assume, NSUserDefaults?) through a button action. Let me back up and explain. What I have right now are 2 TextFields a label and a button. The user will type in measurements in the 2 TextFields. When they hit the button the label displays the volume of the measured object in Gallons. That part of it works great.
Then I wanted to give the user options to output the volume in Liters instead of gallons. I would also like to give the user options to type in the measurements in Centimeters. So I setup a 'Settings.Bundle' and configured it with 2 'Multi Value' cells (Measurement units and Volumetric Units). Each Multi Value cell has its own list of different units the user can pick from.
My main issue is I don't know how to access these settings through the button action. I may be thinking of this wrong, but what I'm looking for is something like;
Button Action
If settings key = 0
Then do the math in Inches, Display in Gallons
If settings key = 1
Then do the math in Centimeters, Display in Gallons
If settings key = 2
Then do the math in Inches, Display in Liters
If settings key = 3
Then do the math in Centimeters, Display in Liters
Etc...
Is this possible? Am I thinking of this in the wrong way? What's the best way to do this?
© Stack Overflow or respective owner