iphone - If/Then statements using UISwitch in xcode -


i trying app run 1 mathematical formula when uiswitch set "on" position, , when it's set "off" position.

i'm trying lay out this:

if switch = on, [first formula]

if switch = off, [second formula]

how code this?

=============
edit:

this how trying code it.

-(ibaction)switchvaluechanged:(uiswitch *)sender { if(sender.on) { -(float)conver2inches: (nsstring *)mmeters { return [mmeters floatvalue]/25.4f; }  -(ibaction)calculate:(id)sender{ float answer = [self conver2inches:entry.text];  output.text=[nsstring stringwithformat:@"%f",answer];}}  else{ -(float)conver2mmeters:(nsstring *)inches {     return [inches floatvalue]*25.4f; } -(ibaction)calculate:(id)sender{     float answer = [self conver2mmeters:entry.text];     output.text=[nsstring stringwithformat:@"%f",answer]; }} } 

you need hook function uiswitch's value changed uievent.

-(ibaction) switchvaluechanged:(uiswitch *) sender {     if(sender.on)     {     ...     }     else     {     ...     } } 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -