Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SwiftUI Freed From ViewController

SwiftUI Freed From ViewController

SwiftUI による ViewController からの解放

Mobile Act OSAKA #10
https://mobileact.connpass.com/event/130913/

ブログ記事
https://usami-k.hatenablog.com/entry/2019/07/27/102920

USAMI Kosuke

July 26, 2019
Tweet

More Decks by USAMI Kosuke

Other Decks in Programming

Transcript

  1. ͢΂ͯͷAppleϓϥοτϑΥʔϜͰ • ैདྷ͸ iOS / watchOS / tvOS / macOS

    ͰҟͳΔϑϨʔ ϜϫʔΫͩͬͨ • ࠓޙ͸ SwiftUI Λ֮͑Ε͹શ෦࡞ΕΔ
  2. SwiftUI Ͱ͸ • View • UIύʔπͷϨΠΞ΢τ • ը໘ͷϥΠϑαΠΫϧॲཧ • Combine

    • Ϣʔβ͔ΒͷೖྗΛड͚෇͚Δ • σʔλͷมߋΛը໘ʹग़ྗ͢Δ
  3. ໾ׂͷ෼཭ • ΞʔΩςΫνϟઃܭͰ͸ View ͱ Model ͷ෼཭͕େࣄ • ͦͷͨΊʹ View

    ͱσʔλόΠϯσΟϯάͱͷ෼཭͕େࣄ • ViewController ͸ͦͷ෼཭Λ๦͕͛ͪͩͬͨ • SwiftUI ͸ View ͱ Combine ͱʹ෼཭ͨ͠
  4. ֤छΞʔΩςΫνϟͷ࣮૷ͷ࠶ߟ • MVCɺMVVMɺClean ArchitectureɺFlux ͳͲͰɺ ViewController ΛͲ͜ʹҐஔ͚ͮΔ͔೉͍͠ • View ͳͷ͔

    Controller ͳͷ͔ Presenter ͳͷ͔ɺ ͋Δ͍͸ผͷԿ͔͔ • SwiftUI Ͱ͸ͦͷ೰Έ͔Β͸ղ์͞ΕΔ • ͨͩ͠σʔλόΠϯσΟϯάͷѻ͍ํ͸ࠓޙͷ՝୊
  5. UIKit Λར༻͢Δ • ݱঢ়Ͱ͸ɺUIKit ͰͰ͖͍ͯͨ͜ͱ͕ SwiftUI ͰͰ͖ͳ͍ έʔε͕͋Δ • UIίϯϙʔωϯτ͕଍Γͳ͍ʢࠓޙ௥Ճ͞ΕΔ͔Ͳ͏͔͸ͳ

    Μͱ΋ݴ͑ͳ͍ʣ • ͦͷͨΊɺ෦෼తʹ͸ UIView ΍ UIViewController ͷॿ ͚ΛआΓΔඞཁ͕ग़ͯ͘Δ
  6. ݁ہ ViewController ࢖ͬͯΔ Ͷʁ • ͱ͸͍͑ɺSwiftUI ͷ View ͷ࿮૊Έʹ͸͓͞·͍ͬͯΔ •

    ΞʔΩςΫνϟઃܭͱͯ͠͸ɺViewController Λҙࣝ͠ͳ ͯ͘ྑ͘ͳͬͨ͜ͱʹมΘΓ͸ͳ͍
  7. ·ͱΊ • SwiftUI ͷಋೖʹΑͬͯɺΞʔΩςΫνϟઃܭͷࡍʹ ViewController ʹ͍ͭͯ಄Λ೰·ͤΔඞཁ͸ͳ͘ͳͬͨ • γϯϓϧͳ࣮૷Ͱ UI ͕࡞ΕΔΑ͏ʹͳͬͨ

    • ৽͍͠σʔλόΠϯσΟϯάͷ࢓૊ΈʢSwiftUI + CombineʣΛͲͷΑ͏ʹΞʔΩςΫνϟઃܭͱ༥࿨ͤ͞Δ͔͸ ࠓޙͷ՝୊
  8. ࢀߟࢿྉ • SwiftUI (https://developer.apple.com/xcode/ swiftui/) • SwiftUI Tutorials (https://developer.apple.com/ tutorials/swiftui/)

    • SwiftUI References (https:// developer.apple.com/documentation/swiftui/) • WWDC19 Videos