The UIViewController is the logical place to start working on your UI code. Then data formats started to change, UI evolved and needed some radical changes, and you just kept adding more ifs into an already massive if-ology.īut, how come the UIViewController is what got out of hand? #SWIFT PUBLISHER 4 TUTORIAL CODE#The ViewController kept growing when the user authorization code came along. Or, even worse, you did that inside the same method. json, so you wrote yet another temp method to accomplish that. Next, you needed to process the data inside that. You were in a rush to see how the back-end data was behaving inside the UITableView, so you put a few lines of networking code inside a temp method of the ViewController just to fetch that. The likely reason is something like this: Your ViewController code has become the infamous spaghetti code. All that code imprisoned inside if-ology of a single file that cannot be reused and would only fit in this project. Networking code, data parsing code, data adjustments code for the UI presentation, app state notifications, UI state changes. In no time, your starting ViewController has become too smart and too massive. There comes the Model-View-ViewModel (MVVM) design pattern that saves the day. However, this pattern has its own issues. The first step to resolve this is to apply the Model-View-Controller (MVC) design pattern. You ended up with a lot of spaghetti code. Suddenly, you have more than 3,000 lines of code. However, it’s time to do something with all these UI elements UIButtons will receive finger touches, UILabels and UITableViews will need someone to tell them what to display and in what format. IBOutlets and IBActions are also included. UITextField here, UITableView there, a few more UILabels and a pinch of UIButtons. You start transferring UI screens from the designer’s sketches into your ViewController. sketch documents, and you already have a vision about how you’ll build this new app. So you’re starting a new iOS project, you received from the designer all the needed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |