ios - Why isn't this If argument being implemented? -


i asked question earlier (stop segue , show alert partially not working - xcode)

and received answers asked me implement different methods of checking textfield before segue. however, realised amiss because 1 of if arguments being run fine.

this code:

import foundation import uikit import darwin  class view3on3 : uiviewcontroller, uitextfielddelegate {  @iboutlet weak var apteams: uitextfield! @iboutlet weak var aprounds: uitextfield! @iboutlet weak var apbreakers: uitextfield!   override func viewdidload() {     super.viewdidload()     initializetextfields() }   func initializetextfields() {     apteams.delegate = self     apteams.keyboardtype = uikeyboardtype.numberpad      aprounds.delegate = self     aprounds.keyboardtype = uikeyboardtype.numberpad      apbreakers.delegate = self     apbreakers.keyboardtype = uikeyboardtype.numberpad }  override func touchesbegan(touches: set<uitouch>, withevent event: uievent?){     view.endediting(true)     super.touchesbegan(touches, withevent: event) }       override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {          if (apteams.text!.isempty || aprounds.text!.isempty || apbreakers.text!.isempty)         {             let alertcontroller: uialertcontroller = uialertcontroller(                 title: "data missing!",                 message: "please enter valid data 3 fields.",                 preferredstyle: uialertcontrollerstyle.alert)              let okaction = uialertaction(                 title: "ok",                 style: uialertactionstyle.default,                 handler: nil)              alertcontroller.addaction(okaction)              presentviewcontroller(alertcontroller, animated: true, completion: nil)         }          else if (int(string(apteams.text)) < int(string(apbreakers.text)))         {             let alertcontroller: uialertcontroller = uialertcontroller(                 title: "math error!",                 message: "the number of breaking teams cannot more number of teams.",                 preferredstyle: uialertcontrollerstyle.alert)              let okaction = uialertaction(                 title: "ok",                 style: uialertactionstyle.default,                 handler: nil)              alertcontroller.addaction(okaction)              presentviewcontroller(alertcontroller, animated: true, completion: nil)         }          else if (int(string(apteams.text)) > 9999)         {             let alertcontroller: uialertcontroller = uialertcontroller(                 title: "math error!",                 message: "the number of breaking teams cannot more number of teams.",                 preferredstyle: uialertcontrollerstyle.alert)              let okaction = uialertaction(                 title: "ok",                 style: uialertactionstyle.default,                 handler: nil)              alertcontroller.addaction(okaction)              presentviewcontroller(alertcontroller, animated: true, completion: nil)         }          else         {             let destviewcontroller : view3on3results = segue.destinationviewcontroller as! view3on3results              destviewcontroller.ap1 = apteams.text!             destviewcontroller.ap2 = aprounds.text!             destviewcontroller.ap3 = apbreakers.text!          }          } } 

it's running textfield input through first if function fine. screenshots here:

enter image description hereenter image description here

but when key in (which should fulfil first else if function , show alert:

enter image description here

it segues normal.

why happening? appreciated. =)

else if (int(string(apteams.text)) < int(string(apbreakers.text))) 

this not executing because not true. split up, convert strings ints first before check , compare ints directly in statement.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -