Bonjour,
J'ai créé une fonction qui est appelée par plusieurs boutons. En fonction du label du bouton appelé je veux faire une instruction différente.
J'ai réussi avec un if/else if mais je n'arrive pas à faire un switch case.
Mon code :
J'ai l'erreur suivante : Binary operator '~=' cannot be applied to operands of type 'String' and 'String?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 var sButtonLabel = sender.titleLabel?.text?.lowercaseString if ( sButtonLabel != nil ) { switch sButtonLabel { case "black": view.backgroundColor = UIColor.blackColor() case "magenta": view.backgroundColor = UIColor.magentaColor() case "white": view.backgroundColor = UIColor.whiteColor() } }
Pouvez-vous me dire ou est mon problème ?
Merci
Partager