- iOS 12 Programming for Beginners
- Craig Clayton
- 118字
- 2021-07-02 15:04:52
Why constants versus variables?
You might be asking yourself "Why would you ever want to make something constant?". Since constants cannot change after you run your app, they keep you from accidentally breaking a value that should not change. Another excellent use for constants is for base URLs, as you would not want these to change. When you are getting data, you do not want to change the value midway through your app accidentally. Apple recommends that you use let whenever possible. Typically, I use let until Xcode warns me that a var is preferable. If I change the value from let to var, then I am verifying that this is the behavior I want.
推薦閱讀
- 通信網(wǎng)絡(luò)基礎(chǔ)與設(shè)備
- RCNP實(shí)驗(yàn)指南:構(gòu)建高級(jí)的路由互聯(lián)網(wǎng)絡(luò)(BARI)
- Django 2 by Example
- TCP/IP入門經(jīng)典(第5版)
- Force.com Development Blueprints
- Proxmox High Availability
- 計(jì)算機(jī)網(wǎng)絡(luò)安全實(shí)訓(xùn)教程(第二版)
- Practical Web Design
- Learning Swift(Second Edition)
- Learning Windows 8 Game Development
- 物聯(lián)網(wǎng)頂層設(shè)計(jì)與關(guān)鍵技術(shù)
- Implementing NetScaler VPX?
- 云工廠:開啟中國(guó)制造云時(shí)代
- 全聯(lián)網(wǎng)標(biāo)識(shí)服務(wù)
- 圖解物聯(lián)網(wǎng)