Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript

Introduction

Async calls in iOS

Updating views

"Draw-Redraw" code of views

What's the problem?

M odel

V iew

C ontroller

From "MVC" to "MVCS"

What does "Controller" actually control?

  • Flow of views - Navigation
  • Flow of logics - Domain Logic

M odel

V iew

C ontroller

S ervice

Async-proof view controllers

Thank you for listening!

BPStudy #46

~ To make your UIViewController Async-proof ~

Traditional (Web) MVC

iOS MVC

2 different "Controller"s

from "Patterns of EnterPrise Application Architecture", Martin Fowler

Model View Controller

Application Controller

Agenda

to

Use-case Controller

(a.k.a. Service Layer)

  • Introduction
  • Async calls in iOS
  • What's the problem?
  • From "MVC" to "MVCS"
  • Async-proof view controllers
  • Conclusion

We need Services

for reusability

for maintenancability

for testability

In App Purchase

Network

Location (GPS)

Too many types of codes in a single view controller! ><

Media Playback

"Draw-Redraw" doesn't work on async codes

Apple Push Notification

"Instanciate-Update-Layout" view outlets

Extra caution for Core Data usage in view controller

Instanciate

API request finished

Location changed

device rotation

Think before retaining

Instanciate = Instanciate

Copy before using many-to-many

Update

NEVER update without lock

So...

Update = Update

Consider using value objects

Layout = Layout

Layout

Hard to chain

Unpredictable timings

Working with async is

  • NO deadly deallocation / reinstanciation

HARD

Decouple "Domain Logic" from view controllers

Multithreading

"Instanciate-Update-Layout" architecture

Draw =

Instanciate

+

Layout

Conclusion

Redraw =

Deallocate

+

Instanciate

+

Layout

Potential memory leak

or

CRASH

Learn more about creating dynamic, engaging presentations with Prezi