Recent Comments
- Today
- 34
- Total
- 229,869
Notice
개발은 너무해
버튼을 통한 Boolean 본문
반응형
동일한 버튼을 클릭할 때마다 boolean 값을 바꿔주는 경우가 종종 있다.
이런 경우 아래와 같이 했었다.
var buttonValue = false @IBAction func BoolButton(_ sender: UIButton) { if buttonValue == true { buttonValue = false } else { buttonValue = true } } |
이것을 단순하게 바꿔본다면...
var buttonValue = false @IBAction func BoolButton(_ sender: UIButton) { buttonValue = !buttonValue } |
끝!
반응형
'iOS-Develop(Swift)' 카테고리의 다른 글
[ERROR] csqlite, stdatomic.h (0) | 2017.05.18 |
---|---|
background to foreground (0) | 2017.04.27 |
버튼을 통한 Boolean (0) | 2017.04.17 |
xcode에서 시뮬레이터가 보이지 않을 때 (0) | 2017.03.10 |
swift3 Bool 기본값 (0) | 2017.01.31 |
[ERROR] Cocoapods : Abort trap: 6 (0) | 2017.01.13 |
0 Comments