ios - If - else in Swift -


i can alert show, has problems:

  1. the title not appear
  2. i can't if statement part work. alert pops showing only:

    the message numbers must 24 or less

    along close button , never changes.

using xcode 6.3 , ios 8.

var title: string!  if difference > hourslabel {     title = "sorry!" } else if difference < hourslabel {     title = "that's better!" }  let message =  "number must 24 or less" var alert = uialertcontroller(title: title, message: message, preferredstyle: uialertcontrollerstyle.alert)  alert.addaction(uialertaction(title: "close", style: .default, handler: nil))  self .presentviewcontroller(alert, animated: true, completion: nil) 

based on provided, seems problem using else if, rather else only

solution 1:

var title: string!  if difference > hourslabel {     title = "sorry!" } else {     title = "that's better!" } 

solution 2:

let title = (difference > hourslabel) ? "sorry": "that's better!" ; 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -