iphone - Using enum and switch case combination in Swift -
this question has answer here:
here code:
enum gamescreen { case ksceneflashscreen case kscenemainmenu case kscenegamescreen case kscenestorescreen case kscenegameover } class ysgamemanager: nsobject { func replacegamescene(inscreen: gamescreen) { switch inscreen { case gamescreen.kscenegamescreen: //error here case gamescreen.kscenemainmenu : //here error } } } eror log: 'case' label in 'switch' should have @ least 1 executable statement
how use enum in switch case in swift ?
there's error because haven't got after : , before next case. solve can:
1. add code something.
2. add fallthrough if want move next case. may have been trying do. however, in swift, switch statements don't fallthrough default next case, break.
3. add break stop switch statement.
Comments
Post a Comment