Section 1

Preview this deck

Keyword 'defer'?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (24)

Section 1

(24 cards)

Keyword 'defer'?

Front

- defines a block to execute when the current scope completes - use when you want to make sure something happens at the end, but semantically it looks neater to write at the beginning (balancing open/close calls) - 'defer' calls happen in reverse order to which they're declared

Back

4 QoS class properties?

Front

- user-interactive - runs on main thread, for UI work - user-initiated - async tasks started from UI - utility - long-running tasks, low-priority, energy-efficient - background - tasks that user will never see

Back

Deadlock?

Front

- when queue never completes because two tasks are waiting for the other to finish - thread1 accesses func1 and gets lock1. thread2 accesses func2 and gets lock2. thread1 wants func2 but is locked out; thread2 wants func1 but is locked out

Back

App delegate method offering first chance to run code?

Front

willFinishLaunchingWithOptions

Back

MVVM?

Front

- use when model needs to be transformed before display, and you don't want that logic in the VC - VM can be wrapper around model, with methods that make it easy to present in a View - VM, if meant to be used with only one view, can contain logic to accept the UIVIew and configure it to display the model

Back

How to resolve reader-writer with GCD?

Front

- barrier flags - when used, guarantees that when the DispatchWorkItem executes, the thread will temporarily become serial

Back

DispatchQueue syntax?

Front

- can define async, or not - can define qos - can define custom queue with label and attributes (concurrent/serial) - can define flags (barrier)

Back

3 ways of passing data between ViewControllers?

Front

- delegate - backward - directly set the variable - forward - prepareForSegue - forward

Back

When is 'willTerminate' called? What is it for?

Front

- triggered by termination event, ie force-quitting or turning off the phone - use to save app state

Back

When is 'didFinishLaunchingWithOptions' called? What is it for?

Front

- app is launched after termination, state has been restored, we're about to present UI - final tweaks before UI is displayed - has access to launch option keys detailing how or why the app was launched

Back

When is 'willResignActive' called?

Front

- temporary events, ie phone calls - use to pause things, clean up, save things, before phone goes inactive - active -> inactive

Back

When is 'willEnterForeground' called? What is it for?

Front

- before app goes from back- to foreground - background -> inactive - use to restore settings of previous running state, undo anything you did in didEnterBackground

Back

When is 'willFinishLaunchingWithOptions' called? What is it for?

Front

- called before state has been restored, before didFinishLaunchingWithOptions - inactive state - initialize window here if app is depending on state restoration for displaying view controllers - has access to launch option keys detailing how or why the app was launched

Back

App delegate method called while app is running in the background with no display?

Front

didEnterBackground

Back

When is 'didBecomeActive' called? What is it for?

Front

- called when active, whether from launch, or switch from another app/call/sms - use to restore state if you had to pause state before going inactive - inactive -> active

Back

App delegate method called before temporary events, like phone calls?

Front

willResignActive

Back

App delegate method called when moving from back- to foreground, offering chance to restore state?

Front

willEnterForeground

Back

App delegate method called on launch, or when switching from another app?

Front

didBecomeActive

Back

Keyword 'mutating'?

Front

- allows change of properties of value types, which are normally immutable - ie you would need to make struct methods mutating if you wanted to change its properties

Back

DispatchQueue description?

Front

- contains static properties for main and global - can be serial / concurrent - can be instantiated for a custom queue - FIFO

Back

App delegate method called when launch is almost complete, before user sees UI?

Front

didFinishLaunchingWithOptions

Back

When is 'didEnterBackground' called? What is it for?

Front

- when running in background where interface is not displayed - inactive -> background - use to save state disk, since app will enter suspended state soon, where it can be terminated

Back

3 types of DispatchQueue?

Front

- main - runs on main thread, serial - global - 5 concurrent ones, comes in high/default/low/background priority that differ in QoS - custom

Back

App delegate method triggered by termination state, like force close or phone shutdown?

Front

willTerminate

Back