Sunday 15 June 2014

swift - When if/else condition is true, executes code in true and false blocks -


In fact, something strange is happening, and I do not understand how it is possible. I'm new to fasting, so I'm missing something, if I need to, I can post more codes, but what I am doing, how can this be done?

  if sender.on {txtNumMavericks.hidden = false} else {txtNumMavericks.hidden = true}  

In this case, the sender is a switch when the switch Is false, then in the second part of the block, as expected, but when it is true, it executes both the top and bottom statements (txtNumMavericks is visible and then disappears immediately). I found it if I put a breakpoint on the single statement through code with F5.

If you just want to toggle the properties that you have to do, add an exclamation mark "!" Follow the real estate front:

  txtNumMavericks.hidden =! TxtNumMavericks.hidden  

No comments:

Post a Comment