MVVM with UITableViews — Using forms (part 2)

  • It contains multiple sections and different kinds of input cells: picker, switch, text field cells etc.
  • One section can be shown or hidden depending of values chosen in another section.
  • Every section will have validation on it’s cells
  • Each section might have some logic for showing / hiding cells depending of the category of the place shown.
  1. Base info section, contains the name, description and category for a place.
  2. Place details section has many details about the place like length, width, area etc. Depending of the place of the category (river, lake or mountain) has other properties specific to it.
  3. Location info section, contains the country and a switch for whether the forth section for coordinates should be shown.
  4. Coordinates section has two fields for the coordinates of a place.
  5. Button section is just the button cell for submitting the form.
Place form for editing and adding new place
  1. PlaceDetailsVC — the main view controller for the form. Handles strictly the UI things: registering cells, updating view, handling keyboard and picker view (~120 lines of code).
  • Sets up all the sections
  • Handles all updates from the cells it knows whether to show / hide a section or just propagate the data to its corresponding section.
  • Properties for the cells data
  • Computed properties that generate the view models for its cells
  • Validation of the fields
  • Updating of the data properties
  • Same concept as previously except that these cells contain delegates conforming to PlaceDetailsVMUpdateDelegate for sending updates when the user enters text, flicks the switch or clicks on the picker label.
Place details screen test examples





iOS Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Documentation Portal as a Service

Thoughts on using for data modelling — common properties

A Comprehensive Guide to Building Fast Apps with Flutter

Sanctum with Socialite: API Authentication via Social Networks in Laravel 8

CS373 Spring 2022: Alex Chandler: Final Entry

Case XX: From thousand to ten millions for 10k

Running MongoDB 5.0 Cluster on AWS Graviton 3 or why I dont use MongoDB Atlas

Agile Instructional Design at LinkedIn to Create Engaging Courses

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


iOS Developer

More from Medium

Learn how to setup a basic CI-CD environment for your iOS projects by configuring Gitlab-CI and…

Handling dynamic JSON value using Decodable

Modifying iOS SMS database

SOLID Principles in Swift — Liskov Substitution Principle