Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get value of segmented control on flipside view for mainview Calculation?

How do you get value of segmented control on flipside view for mainview Calculation?

like image 337
Jason Avatar asked Dec 08 '25 12:12

Jason


1 Answers

Make a variable in your Controller (not your view, link your actions from your view to the controller in Interface Builder). Then you can do two things:

a) When this:

-(IBAction)CalculateButton:(id)sender

is triggered. Let the controller get the values from the flip side view and do the calculation.

b) Make a Model object (maybe very advanced for the size of the app, but its a good design and a best practice)

@interface CalculateObject : NSObject {
   //Some variables
}
//@property for all variables

- (...) doCalculation;
@end

When the segment controls change and the controller receives the action, call the correct setter in your model. Then when the calculate button is called. Just call the doCalculate method.

Note: I'm not sure if you know about the Model-View-Controller pattern, but if you don't see:

http://en.wikipedia.org/wiki/Model–View–Controller

like image 163
Mats Stijlaart Avatar answered Dec 11 '25 05:12

Mats Stijlaart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!