Skip to content

Latest commit

ย 

History

History
83 lines (67 loc) ยท 4.76 KB

Architecting_Multiple_Windows.md

File metadata and controls

83 lines (67 loc) ยท 4.76 KB
layout title date categories tags author mathjax comments
post
Architecting Your App for Multiple Windows
2019-11-06 21:26:06 +0900
iOS
iOS Windows WWDC
Juhee Kim
true
true
  • content {:toc}

๋“ค์–ด๊ฐ€๊ธฐ์— ์•ž์„œ์„œ

iOS 13์—์„œ๋ถ€ํ„ฐ ๋ฉ€ํ‹ฐ ์œˆ๋„์šฐ๋ฅผ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ์กด ์•ฑ์„ ๋”์šฑ ์œ ์šฉํ•˜๊ฒŒ ๋งŒ๋“ค๊ณ  ์‚ฌ์šฉ์ž์˜ ์ƒ์‚ฐ์„ฑ์„ ํฌ๊ฒŒ ํ–ฅ์ƒ์‹œํ‚ค๋Š” ํ™˜์ƒ์ ์ธ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ์ด ์„ธ์…˜์€ ๋‹ค์Œ ์„ธ ๊ฐ€์ง€๋ฅผ ๋‹ค๋ฃน๋‹ˆ๋‹ค.

  • Changes to app lifecycle
  • Using them scene delegate : UISceneDelegate๋ฅผ ์•Œ์•„๋ณด๊ณ  ์–ด๋–ค ์ž‘์—…์„ ํ•ด์•ผํ•˜๋Š”์ง€
  • Architecture: ๋” ๋‚˜์€ ๋ฉ€ํ‹ฐํƒœ์Šคํ‚น์„ ์œ„ํ•œ Architecture Kit์˜ ๋ชจ๋ฒ”์‚ฌ๋ก€

Changes to app lifecycle

๊ธฐ์กด App Delegate์˜ ์—ญํ• 

  • Application์˜ ํ”„๋กœ์„ธ์Šค ๋ ˆ๋ฒจ ์ˆ˜์ค€ ์ด๋ฒคํŠธ๋ฅผ ์•Œ๋ ค์ฃผ๋Š” ์ผ
    • ์•ฑ ์‹œ์ž‘/๋Œ€๊ธฐ/์ข…๋ฃŒ
    • ๊ทธ ์™ธ ๊ฐ์ข… ๋…ธํ‹ฐ ์ˆ˜๋ ด
  • Application์˜ UI ์ƒํƒœ๋ฅผ ์•Œ๋ ค์คŒ
    • ํฌ๊ทธ๋ผ์šด๋“œ/๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ด๋™
    • ResignActive/BecomeActive

iOS 12 ๋ฐ ์ด์ „ ๋ฒ„์ „์—์„œ๋Š” ํ•˜๋‚˜์˜ Application ํ”„๋กœ์„ธ์Šค์™€ ํ•˜๋‚˜์˜ UI ์ธ์Šคํ„ด์Šค๋งŒ ์กด์žฌํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ด€๊ณ„์—†์ง€๋งŒ, ๊ทธ ์ดํ›„์—๋Š” ์—ฌ๋Ÿฌ ํ™”๋ฉด์ด ์กด์žฌํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ App Delegate์˜ ์—ญํ• ๊ณผ ์ฑ…์ž„์ด ๋ฐ”๋€Œ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

Using the Scene Delegate

  • App Delegate : Application์˜ ํ”„๋กœ์„ธ์Šค ๋ ˆ๋ฒจ ์ˆ˜์ค€ ์ด๋ฒคํŠธ๋ฅผ ์•Œ๋ ค์ฃผ๋Š” ์ผ
    • ์•ฑ ์‹œ์ž‘/๋Œ€๊ธฐ/์ข…๋ฃŒ
    • ๊ทธ ์™ธ ๊ฐ์ข… ๋…ธํ‹ฐ ์ˆ˜๋ ด
    • ํ™”๋ฉด(scene)์ด ์ƒ์„ฑ/์‚ญ์ œ๋˜์—ˆ์„ ๋•Œ ์•Œ๋ฆผ
  • Scene Delegate : Application์˜ UI ์ƒํƒœ๋ฅผ ์•Œ๋ ค์คŒ
    • ํฌ๊ทธ๋ผ์šด๋“œ/๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ด๋™
    • ResignActive/BecomeActive

ํ•˜์ง€๋งŒ iOS 12 ๋ฐ ์ด์ „ ๋ฒ„์ „์„ ์œ ์ง€ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” AppDelegate ๋กœ์ง์„ ์œ ์ง€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค..!

Scene lifecycle

  • App Delegate
    • didFinishLaunchingWithOptions(:)
    • create scene session
    • configure UIScene
      • specify UISceneDelegate, Storyboard, Subclass View
      • ํ˜น์€ info.plist์—์„œ ์ •์˜
  • Scene Delegate
    • willConeectToSession(:)
    • willResignActive, didEnterBackground
    • didDisconnected
      • ํ™”๋ฉด์ด ๋ฐฑ๊ทธ๋ผ์šด๋“œ์— ๋“ค์–ด๊ฐ€๋ฉด ์‹œ์Šคํ…œ์— ์˜ํ•ด์„œ disconnected ๋  ์ˆ˜ ์žˆ๋‹ค.
      • ๊ทธ๋ž˜์„œ ๋‚˜์ค‘์— ์—ฐ๊ฒฐ๋  ๋•Œ๋ฅผ ๋Œ€๋น„ํ•ด์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•ด์•ผํ•  ํ•„์š”์„ฑ์ด ์žˆ๋‹ค. *App Delegate
    • ์‚ฌ์šฉ์ž๊ฐ€ ํ™”๋ฉด์„ ์—†์• ๋ฉด didDiscardSceneSession์ด ํ˜ธ์ถœ๋œ๋‹ค.

Cleanning up Discarded Session

ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‹คํ–‰์ค‘์ด ์•„๋‹Œ ๊ฒฝ์šฐ ์‹œ์Šคํ…œ์€ discard๋œ ์„ธ์…˜์„ ์ถ”์ ํ•˜๊ณ  ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์‹คํ–‰๋œ ์งํ›„ ์ด๋ฅผ ๋‹ค์‹œ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค.

Architecture

State Restoration

์•ฑ์˜ ํ™”๋ฉด์ด ์—ฌ๋Ÿฌ ๊ฐœ๊ฐ€ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ํ™”๋ฉด์— ๋Œ€ํ•œ ๋ณต๊ตฌ๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ๋งŒ์ผ ์ƒํƒœ ๋ณต์›์„ ๊ตฌํ˜„ํ•˜์ง€ ์•Š์œผ๋ฉด ๋ฉ€ํ‹ฐ ์œˆ๋„์šฐ ์ƒํƒœ์—์„œ disconnect ๋œ ํ›„ ๋‹ค์‹œ ์—ฐ๊ฒฐ๋˜์—ˆ์„ ๋•Œ ์™„์ „ํžˆ ์ƒˆ๋กœ์šด ํ™”๋ฉด์ด ๋œฐ ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์— ์ข‹์ง€ ์•Š์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ iOS 13์—์„œ๋Š” ์ด๋ฅผ ์ง€์›ํ•˜๊ธฐ ์œ„ํ•ด State Restoration API๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ƒํƒœ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ™”๋ฉด์„ ์ธ์ฝ”๋”ฉํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ ์ด๋Š” NSUserActivity๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค.

  • ์ด๋Š” spotlightsearch๋‚˜ handoff์—๋„ ์ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • session์ด stateRestorationActivity๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๋ฉด ์ด๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ™”๋ฉด์„ ๊ตฌ์„ฑํ•˜๊ณ , ๊ทธ๋ ‡์ง€ ์•Š๋‹ค๋ฉด ์ƒˆ๋กœ์šด ํ™”๋ฉด์„ ๊ตฌ์ƒํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

Application Sync

๋งŒ์•ฝ ์ฑ„ํŒ… ํ™”๋ฉด์„ ์—ฌ๋Ÿฌ ๊ณณ์—์„œ ๋„์šด๋‹ค๋ฉด? ๊ฐ™์€ ์ฑ„ํŒ…๋ฐฉ์„ ์—ฌ๋Ÿฌ ์ฐฝ์—์„œ ๋„์šธ ๋•Œ ๋™๊ธฐํ™” ๋ฌธ์ œ๋ฅผ ์–ด๋–ป๊ฒŒ ํ•ด์•ผํ• ๊นŒ์š”?

  • ViewController๊ฐ€ ์ด๋ฒคํŠธ๋ฅผ ์ˆ˜์‹ ํ•˜๋ฉด Model Controller์— ๋‹ค์‹œ ์ด๋ฒคํŠธ๋ฅผ ์ „๋‹ฌ
  • Model์„ ๊ตฌ๋…ํ•˜๊ณ  ์žˆ๋Š” ๊ตฌ๋…์ž ํ˜น์€ View Controller์—๊ฒŒ ์ƒˆ๋กœ์šด ๋ฐ์ดํ„ฐ๊ฐ€ ์—…๋ฐ์ดํŠธ ๋˜์—ˆ์Œ์„ ์•Œ๋ฆผ

์‹ค์ œ ๊ตฌํ˜„ ๋ฐฉ์‹์œผ๋กœ๋Š” Delegate์™€ Notification, Swift Combine์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • View Controller๊ฐ€ ์Šค์Šค๋กœ View๋ฅผ ์—…๋ฐ์ดํŠธํ•˜์ง€ ์•Š๊ณ , Model์ด ์—…๋ฐ์ดํŠธ ๋จ์— ๋”ฐ๋ผ View๊ฐ€ ์ž๋™์œผ๋กœ ์—…๋ฐ์ดํŠธ ๋˜๋„๋ก ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.

Summary

์šฐ๋ฆฌ๋Š” AppDelegate์™€ SceneDelegate์˜ ์ฐจ์ด์ ๊ณผ ์ฑ…์ž„์˜ ์ฐจ์ด์— ๋Œ€ํ•ด ์‚ดํŽด ๋ณด์•˜์Šต๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ๋˜ํ•œ ๋ช‡ ๊ฐ€์ง€ ์ฃผ์š” SceneDelegate``method๋ฅผ ์•Œ์•„๋ณด๊ณ  ์—ฌ๊ธฐ์—์„œ ์–ด๋–ค ์ข…๋ฅ˜์˜ ์ž‘์—…์„ ํ•ด์•ผํ•˜๋Š”์ง€ ์‚ดํŽด ๋ณด์•˜์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ iOS 13์—์„œ ์ƒํƒœ ๋ณต์›์ด ์ค‘์š”ํ•œ ์ด์œ ์™€ ์ƒˆ๋กœ์šด ์žฅ๋ฉด ๊ธฐ๋ฐ˜ API๋ฅผ ํ™œ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด์„œ๋„ ์„ค๋ช…ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ, ๋‹จ๋ฐฉํ–ฅ ๋ฐ์ดํ„ฐ ํ๋ฆ„์„ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•œ ์ผ๋ถ€ ๊ณ ์ˆ˜์ค€ ํŒจํ„ด์— ๋Œ€ํ•ด ์ด์•ผ๊ธฐํ•˜๋ฉฐ, ๋ชจ๋“  ์žฅ๋ฉด์ด ๋™์ผํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ๊ณต์œ ํ•˜๋Š” ๋™์•ˆ ๋™๊ธฐํ™” ์ƒํƒœ๋ฅผ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜์˜€์Šต๋‹ˆ๋‹ค.