LETSBUILDTHATAPP
HOME
ABOUT US
LOGIN
Login required for access
In order to watch this lesson, you'll need to login to the website.
Proceed to Login
How to Use Enumerations to Prevent Bugs
YouTube
Source
Enumeration is a very powerful concept when building applications that are bug free. Today, I'll show you how to effectively craft your own enumeration to support our menu component setting names. Hope you enjoy!
!codebreak <div class='filename'>SettingName.swift</div> !codebreak !syntax-highlight enum SettingName: String { case Cancel = "Cancel & Dismiss Completely" case Settings = "Settings" case TermsPrivacy = "Terms & privacy policy" case SendFeedback = "Send Feedback" case Help = "Help" case SwitchAccount = "Switch Account" } !codebreak <div class='filename'>SettingsLauncher.swift</div> !codebreak !syntax-highlight let settings: [Setting] = { let settingsSetting = Setting(name: .Settings, imageName: "settings") let cancelSetting = Setting(name: .Cancel, imageName: "cancel") return [settingsSetting, Setting(name: .TermsPrivacy, imageName: "privacy"), Setting(name: .SendFeedback, imageName: "feedback"), Setting(name: .Help, imageName: "help"), Setting(name: .SwitchAccount, imageName: "switch_account"), cancelSetting] }() func handleDismiss(setting: Setting) { UIView.animateWithDuration(0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .CurveEaseOut, animations: { //... }) { (completed: Bool) in if setting.name != .Cancel { self.homeController?.showControllerForSetting(setting) } } } !codebreak <div class='filename'>SettingCell.swift</div> !codebreak !syntax-highlight var setting: Setting? { didSet { nameLabel.text = setting?.name.rawValue //... } } !codebreak <div class='filename'>HomeController.swift</div> !codebreak !syntax-highlight func showControllerForSetting(setting: Setting) { //... dummySettingsViewController.navigationItem.title = setting.name.rawValue //... }
Comments (3)
Submit
6 years ago
Reply
8 years ago
Reply
8 years ago
Reply
7 years ago
Reply
7 years ago
Reply
7 years ago
Reply
8 years ago
Reply
8 years ago
Reply
Introduction - Home Feed Layout
MVC, JSON, and Image Loading
Slide-In Menu
Playing Videos
10.
How to Use Enumerations to Prevent Bugs
13:14
11.
How to Swipe Away Navigation Bar
22:33
12.
How to Swipe between Sections Horizontally
26:17
13.
How to Render Vertical Video Cells in Horizontal Layout
23:16
14.
How to Fetch Multiple Feeds
20:34
15.
How To Parse JSON With Few Lines
31:59
16.
How to Play Video with Animation using AVPlayer
20:15
17.
How to Display Video Player Controls
23:34
18.
How to Seek and Scrub through Video with UISlider
23:59
19.
How to Track Progress of AVPlayer and Bonus Gradients
20:43
Please contact
admin@letsbuildthatapp.com
if you have any issues.
LBTA
LBTA is a platform that strives to teach and demonstrate usage of technologies such as SwiftUI and Javascript to build out full stack applications.
HELP & SUPPORT
About Us
FOLLOW US
YouTube
Twitter