Book
  • Introduction
  • Welcome !!
  • Chapter 1: The mobile ecosystem
    • Fragmentation is the devil
    • There is more than one type of mobile app
    • ... more than one type of app
    • ... one type of app
    • Under pressure (ee da de da de) !!
    • Further reading!!
  • Chapter 2: Let's start with design thinking
    • A taste of design thinking
    • The five steps
    • Design for everybody
    • Accessibility in mobile apps
  • Chapter 3: Give me a context and I will give you an app
    • Users
    • Personas? Users ? What is the difference?
    • Please, help me to model the context
    • The context canvas
  • Chapter 4: Powerful models
    • Data architecture is the foundation of analytics
    • From data to information and knowledge
    • Information/Knowledge in our mobile ecosystem
    • Questions to ask yourselves when building and classifying questions
    • The visualization-data map
    • On the scene: describing how personas interact with your app
  • Chapter 5: A GUI is better than two thousand words
    • 'Good to Go:' Let's explore the Design Systems
    • Designing GUI Mocks
    • No prototype... no deal
  • Chapter 6: About mobile operating systems ... and other deamons
    • The Android OS ... son of LINUX
    • iOS son of Darwin? or is it iOS son of UNIX?
    • Kernels
  • Chapter 7: Yes, software architecture matters !!
    • Self-test time
    • About design and design constraints
    • Architects' mojo: styles and patterns
    • What you need is a tactic !!
    • Self-test time 2 (for real)
    • Further reading
  • Chapter 8: Finally... coding
    • MVC, MVVM, MV*, MV...What?
    • Programming models: the Android side
    • Hello Jetpack, my new friend... An Android Jetpack Introduction
    • Programming models: the iOS side
    • Controllers and more controllers
    • Flutter son of... simplicity
    • Programming models: Flutter?
    • Flutter: State matters... Let´s start simple
    • Flutter: State matters... Complex stuff ahead
    • Micro-optimizations
  • Chapter 9: Data pipeline
    • Generalities data pipelines
    • Data storage types
    • Types of data pipelines
  • Chapter 10: Error Retrieving Chapter 10
    • Eventual Connectivity on Mobile Apps
    • How to handle it on Android
  • Chapter 11: The jewel in the crown: Performance
    • As fast as a nail
    • Memory bloats
    • Energy leaks
    • Final thoughts
  • Chapter 12. Become a performance bugs exterminator
    • Weak or strong?
    • Micro-optimizations
    • The single thread game !!
    • Using multi-threading like a boss !!
    • Caching
    • Avoiding memory bloats
    • Further readings
Powered by GitBook
On this page
  1. Chapter 8: Finally... coding

Programming models: the iOS side

PreviousHello Jetpack, my new friend... An Android Jetpack IntroductionNextControllers and more controllers

Last updated 1 year ago

(By Mario Linares-Vásquez and Laura Bello-Jiménez)


The iOS MVC pattern has been out there for a long time, therefore, it is the de-facto way for implementing iOS apps. The main components of the progamming model are:

  • Controllers: Controllers are the central part in the iOS model because controllers act as mediators between view and model objects. iOS has different types of controllers such as , , , , , among others.

  • Views: view objects are organized in screens (a.k.a., scenes). The screens and views are created via the storyboard editor in XCode. The editor allows developers to (i) visualy design the UI by dragging and dropping components to the scenes, and (ii) set different interaction aspects. Views can interact with controllers via outlets and actions. An outlet is a reference variable created in a controller. Outlets act like view proxies in the controllers for programatically modifying appearence and behavior of view objects (directly in the controller). Actions are listener methods created in the controller; these methods are event handlers for events from the view objects.

Check the tutorial (by Apple) to understand how to build a UI and connect it to View Controllers:

  • Model: object models are abstractions, of the domain model, that encapsulate the data and logic in the application. In that sense, the model is also in charge of persisting data locally in an underlying sqlite database or local files. In the iOS MVC, there should not be connection between the model and the view, because the controller is in charge of (i) notifying the view objects about changes in the model, and (ii) listening for view events and then invoking the model. The main elements to manage the data model are Core Data (to create and manage the model without using SQL queries), NSUserDefaults (to store info related with the user like name, email, preferences, etc), Property Lists or plist (to store small amount of data), NSFileManager (to examine and change content of the file system), SQLite (to store data through tables), among others.

Check the tutorial (by Apple)

  • App Delegate: There is only one app delegate per app. It is the component in charge of dealing with app lifecyle. As an app developer, you must implement the lifecycle methods in the app delegate in order to react to app state transitions, events and notifications. An app delegate looks like the one in the image bellow:

  • Segue: This component is in charge of presenting a new view controller and it can be created via storyboard. It can start with a gesture, button, table row or after a defined time and it can pass information between controllers. Every segue will have an identifier, which will be useful if there are multiple segues per view, also it is possible to perform it in code. There are different ways to present a new view controller (show, show detail, present modally and present) but you must choose the one that fits with your goals. The most used one is "show" because it pushes the selected view on the top of the navigation.

Best practices

Delegation pattern is mostly used among iOS developers, because it allows objects to assign responsabilities (delegate) to another object, it doesn't matter if they have different types. The main behavior of this pattern is: the delegating object mantains a reference to the delegate, when an event occurs, the delegating object handles it and notifies the delegate to update the view or the state of another objects (execute its responsabilities).

As a result, objects inside an app keep coordinated even if changes occur in a distinct side of the app. What's more, objects can change behavior of different objects without inheriting from it.

Delegates are used commonly when a controller triggers a segue and a new view controller is launched. When the new controller finishes its tasks, it notifies and sends information back to its creator. Then the creator updates the view.

Important: delegates are different from App Delegate. There are a lot of delegates but only one app delegate.

Check the UIKit documentation to learn more about the .

Check the UIKit documentation to learn more about .

Check the documentation to learn more about .

Application Delegate
Implement Navigation
Delegates and Data Sources
View Controller
Navigation Controller
Table View Controller
Collection View Controller
Tab Bar Controller
Build a basic UI
Define your data model