我有一个按钮,按钮的标题是一个整数。
correctAnswer = randomNumber1 + randomNumber2
button1.setTitle("\(correctAnswer)", forState: UIControlState.Normal)
我正在尝试检查按钮的标题,因此将其转换为整数并在if语句中使用它,但无法使其工作。
button1.titleLabel?.text?.toInt()
if button1.titleLabel == correctAnswer { //most probably I am making a mistake here.
scoring() } else {
println(button1.titleLabel?.text!)
我是新手,我甚至可能对我的方法有疑问,你的帮助将不胜感激。
答案 0 :(得分:22)
你应该使用button1.currentTitle
答案 1 :(得分:1)
你也应该使用
sender.currentTitle
答案 2 :(得分:0)
您可以尝试使用
SELECT
Units.Clinic,
Units.display_id,
INTAKES.initial_intake_date,
COUNT(case_note_type_desc) AS CountOfUAs
FROM Units
LEFT JOIN (SELECT display_id,Clinic,initial_intake_date
FROM factIntakesAndDischarges
GROUP BY display_id,Clinic,initial_intake_date ) INTAKES
ON Units.display_id = INTAKES.display_id
AND Units.display_id = INTAKES.Clinic
WHERE casenotes_date BETWEEN '4/9/20' AND '5/9/20'
AND case_note_type_desc = '(UA)'
GROUP BY Units.Clinic,
Units.display_id,
INTAKES.initial_intake_date
ORDER BY CountOfUAs desc,Clinic,display_id,initial_intake_date