アプリが動いたその先へ
 (iOS アプリ開発編)

アプリが動いたその先へ
 (iOS アプリ開発編)

6a55a7fb19c1fa78e86ddca7a69db088?s=128

Yuka Ezura

August 18, 2017
Tweet

Transcript

  1. ΞϓϦ͕ಈ͍ͨͦͷઌ΁
 (iOS ΞϓϦ։ൃฤ) 2017/8/18
 ezura

  2. “\(self)” • iOS engineer @ LINE • ֶੜ࣌: Android, iOS

    engineer • Swift, Objective-C, Kotlin, Java, … ezura (@eduraaa)
  3. ୭ͩͬͯ࠷ॳ͸ॳ৺ऀ

  4. ίʔυΛ੾ͬͯష͚ͬͯͬͭͯͨ͘Βɺ
 ΞϓϦ͕Ͱ͖͍ͯͨ ( 'ω')

  5. Α͘Θ͔Βͳ͍ͱ͜Ζ΋͋Δ͚Ͳɺ
 ΞϓϦ͕Ͱ͖͍ͯͨ ( 'ω') retain…, delegate…, 
 tableView…, ฒྻॲཧ…

  6. ͳΜ͔ϝϞϦϦʔΫ͚ͯͨ͠Ͳɺ
 ΞϓϦ͕Ͱ͖͍ͯͨ ( 'ω') ࠭ͷ͓৓ͷΑ͏ͳίʔυ…

  7. ϓϩͱͯ͠ஏ͔ͣ͘͠ͳ͍ɺ
 ΞϓϦΛ࡞Γ͍ͨ ( 'ω') Ͳ͏͢Ε͹ྑ͍ΜͩΖ͏…

  8. ॳ৺ऀͷͱ͖ٙ໰ͩͬͨ͜ͱɺ೰ΜͰͨ͜ͱ
 Α͘ฉ࣭͘໰ weak ͱ strong ͷ࢖͍෼͚ thread ؅ཧͬͯ
 ݁ہͲ͏͢Ε͹ྑ͍ͷʁ งғؾͰ

    thread Λ
 ࢖͍ͬͯΔ ॥؀ࢀরා͍
 Ͳ͏͢Ε͹๷͛Δͷʁ ࣗ෼ͷϓϩάϥϜͷ඼࣭ͬͯ
 ࣮ࡍʹͲͷϨϕϧͳͷ… ຊ౰͸μϝͳ͜ͱΛ
 ΍͍ͬͯΔͷͰ͸… storyboard ͸
 ࢖ͬͨํ͕ྑ͍ͷʁ
  9. ݪଇɾݪཧ
 (جૅ) ঢ়گ + = ౴͑

  10. ࠜຊతͳ෦෼Λ͓͞Β͍͠ͳ͕Β
 ٙ໰Λղܾ͍ͯ͜͠͏ ໨త

  11. index • ࢀরपΓ • thread पΓ • ͦͷଞͷ͜ͱͰ࣭໰ɾ૬ஊ

  12. ࢀরɾϝϞϦपΓ

  13. ॥؀ࢀরΛͲ͏๷͛͹ྑ͍ͷʁ

  14. weak ͱ strong ͷ࢖͍෼͚͸ʁ

  15. ͦ΋ͦ΋ɺstrong ͱ͔ weak ͷࢦఆ͸
 ͳͥඞཁʁʁ

  16. ΦϒδΣΫτΛ࡞Δ ↓ ΦϒδΣΫτͷσʔλΛஔ͍͓ͯ͘৔ॴ͕ඞཁ ↓ ΦϒδΣΫτͷσʔλΛஔ͍͓ͯ͘৔ॴΛϝϞϦ্ʹ֬อ͓ͯ͘͠ object

  17. ΦϒδΣΫτΛ࡞Δ ↓ ΦϒδΣΫτͷσʔλΛஔ͍͓ͯ͘৔ॴ͕ඞཁ ↓ ΦϒδΣΫτͷσʔλΛஔ͍͓ͯ͘৔ॴΛϝϞϦ্ʹ֬อ͓ͯ͘͠ memory object

  18. ΦϒδΣΫτΛ࡞Δ ↓ ΦϒδΣΫτͷσʔλΛஔ͍͓ͯ͘৔ॴ͕ඞཁ ↓ ΦϒδΣΫτͷσʔλΛஔ͍͓ͯ͘৔ॴΛϝϞϦ্ʹ֬อ͓ͯ͘͠ object memory

  19. ͍ͭɺ֬อͨ͠ྖҬΛղ์͢Ε͹ྑ͍ʁʁ object memory

  20. ͍ͭɺ֬อͨ͠ϝϞϦΛղ์͢Ε͹ྑ͍ʁʁ object memory object object ΋͏ೖΒͳ͍…
 མͪΑ…( ˘ω˘) object

  21. object memory object object ΋͏ೖΒͳ͍…
 མͪΑ…( ˘ω˘) ͍ͭɺ֬อͨ͠ϝϞϦΛղ์͢Ε͹ྑ͍ʁʁ ↓ ΦϒδΣΫτ͕ෆཁʹͳͬͨͱ͖

    object
  22. “ཁΒͳ͍” ͬͯɺͲ͏΍ͬͯ൑அ͢Ε͹ྑ͍ʁ

  23. ϝϞϦͷ؅ཧ • Java, Ruby, JavaScript, … • ํ๏: Garbage Collection

    • Ͳ͔͜Β΋ࢀর͞Εͳ͘ͳͬͨΦϒδΣΫτΛ GC ͕ௐ΂ͯղ์
 (ਓ͕؅ཧ͠ͳ͍) • Swift, Objective-C • ํ๏: Reference Counting • ඞཁͳΒΧ΢ϯτΛ૿΍͠ɺཁΒͳ͘ͳͬͨΒΧ΢ϯτΛݮΒ͢
 Χ΢ϯτ͕ 0 ʹͳͬͨΒෆཁͱΈͳͯ͠ղ์
 (Reference Count = ΦϒδΣΫτΛඞཁͱ͍ͯ͠Δ෺ͷ਺)
  24. Reference Counting • Swift, Objective-C • ARC (Automatic Reference Counting)

    • weak ࢀরͱ strong ࢀর • Objective-C (ੲ) • MRC (Manual Reference Counting) • [obj retain] ͱ͔ॻ͍ͯ͋ͬͨΒ͜Ε
  25. Reference Counting • Swift, Objective-C • ARC (Automatic Reference Counting)

    • weak ࢀরͱ strong ࢀর • Objective-C (ੲ) • MRC (Manual Reference Counting) • [obj retain] ͱ͔ॻ͍ͯ͋ͬͨΒ͜Ε
  26. Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ object

  27. Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม਺͕͋Γ·͢ object strong let

    obj = object ࢀরΧ΢ϯτ += 1 
 => 1
  28. Reference Count object strong let obj = object ࢀরΧ΢ϯτ -=

    1 
 => 0 • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม਺͕͋Γ·͢ • strong ࢀর͍ͯ͠Δม਺͕ͳ͘ͳΓ·ͨ͠
  29. Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม਺͕͋Γ·͢ • strong ࢀর͍ͯ͠Δม਺͕ͳ͘ͳΓ·ͨ͠

    • ΦϒδΣΫτ͸ղ์͞Ε·͢ object strong let obj = object ࢀরΧ΢ϯτ 
 => 0
  30. Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ object

  31. Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม਺͕͋Γ·͢ object strong let

    obj = object ࢀরΧ΢ϯτ += 1 
 => 1
  32. Reference Count object strong let obj = object ࢀরΧ΢ϯτ 


    => 1 weak var obj = object • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม਺͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม਺͕͋Γ·͢
  33. Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม਺͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม਺͕͋Γ·͢

    • weak ࢀর͍ͯ͠Δม਺͕ͳ͘ͳΓ·ͨ͠ object strong let obj = object ࢀরΧ΢ϯτ 
 => 1 weak var obj = object
  34. Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม਺͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม਺͕͋Γ·͢

    • weak ࢀর͍ͯ͠Δม਺͕ͳ͘ͳΓ·ͨ͠ object strong let obj = object ࢀরΧ΢ϯτ 
 => 1
  35. Reference Count object strong let obj = object ࢀরΧ΢ϯτ +=

    1 
 => 1 weak var obj = object • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม਺͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม਺͕͋Γ·͢
  36. Reference Count object strong let obj = object ࢀরΧ΢ϯτ -=

    1 
 => 0 weak var obj = object • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม਺͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม਺͕͋Γ·͢ • strong ࢀর͍ͯ͠Δม਺͕ͳ͘ͳΓ·ͨ͠
  37. Reference Count object strong let obj = object ࢀরΧ΢ϯτ
 =>

    0 weak var obj = object • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม਺͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม਺͕͋Γ·͢ • strong ࢀর͍ͯ͠Δม਺͕ͳ͘ͳΓ·ͨ͠ • ΦϒδΣΫτ͸ղ์͞Ε·͢
  38. Reference Count object strong let obj = object ࢀরΧ΢ϯτ
 =>

    0 weak var obj = object • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม਺͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม਺͕͋Γ·͢ • strong ࢀর͍ͯ͠Δม਺͕ͳ͘ͳΓ·ͨ͠ • ΦϒδΣΫτ͸ղ์͞Ε·͢ ஫: nil ͕୅ೖ͞ΕΔΘ͚Ͱ͸ͳ͍
  39. ࢀর strong var obj objA strong var obj objB

  40. ࢀর strong var obj = objB objA strong var obj

    = objA objB
  41. ࢀর strong var obj = objB objA strong var obj

    = objA objB
  42. ࢀর strong var obj = objB objA strong var obj

    = objA objB ॥؀ࢀর
  43. ࢀর strong var obj = objB objA strong var obj

    = objA objB Ͳ͏ͨ͠Βղ์͞ΕΔʁ
  44. ࢀর strong var obj = nil objA strong var obj

    = objA objB ໌ࣔతʹࢀরΛղ͘ඞཁ͕͋Δ
  45. ࢀর strong var obj = nil objA strong var obj

    = objA objB Auto ͱ͸Ұମ… :(
  46. ࢀর strong var obj = nil objA strong var obj

    = objA objB ʮͺͬͱݟΘ͔Βͳ͍͚Ͳɺ~͠ͳ͍ͱ͍͚ͳ͍ʯ
 ͷΑ͏ͳɺ҉໧తྃղͷ͋Δίʔυ͸͍͔ͭഁ໓͢Δ
  47. ࢀর strong var obj = objB objA strong var obj

    = objA objB
  48. ࢀর strong var obj = objB objA weak var obj

    = objA objB
  49. ࢀর strong var obj = objB objA weak var obj

    = objA objB
  50. ࢀর strong var obj = objB objA weak var obj

    = objA objB
  51. ࢀর strong var obj = objB objA weak var obj

    = objA objB
  52. ཧ࿦తʹ͸Θ͔͚ͬͨͲɺ
 Ͳ͏࢖͍෼͚Ε͹ྑ͍ͷʁ Object ؒͷؔ܎ੑ͔ΒܾΊΑ͏

  53. ࢀর strong var obj = objB objA weak var obj

    = objA objB
  54. ParentViewController ChildViewController strong var cvc = cvc weak var delegate

    = ChildViewController pvc ParentViewController
  55. ParentViewController ChildViewController strong var cvc = cvc weak var delegate

    = ChildViewController pvc ParentViewController
  56. ParentViewController
 ChildViewController strong var cvc = cvc weak var delegate

    = ChildViewController pvc ParentViewController
  57. ParentViewController ChildViewController strong var cvc = cvc weak var delegate

    = ChildViewController pvc ParentViewController
  58. ParentViewController
 ChildViewController strong var cvc = cvc weak var delegate

    = ChildViewController pvc ParentViewController
  59. ParentViewController ChildViewController strong var cvc = cvc weak var delegate

    = ChildViewController pvc ParentViewController ParentViewController ͕͍ͳ͘ͳͬͨΒɺ ChildViewController ΋͍Βͳ͘ͳΔؔ܎
  60. weak ͱ strong ͷ࢖͍෼͚͸ʁ Object ؒͷؔ܎ੑ͔ΒܾΊΑ͏

  61. ॥؀ࢀরΛͲ͏๷͛͹ྑ͍ͷʁ લड़ͷ weak, strong ͷ࢖͍෼͚ closure ʹΑΔΩϟϓνϟʹؾΛ͚ͭΔ

  62. ࢀর strong var obj = objB objA strong var obj

    = objA objB
  63. ࢀর object closure object

  64. ࢀর closure object object

  65. ࢀর closure object object ΩϟϓνϟϦετ
 [weak self]

  66. ༨ஊ closure object object ΩϟϓνϟϦετ
 [weak self]

  67. ༨ஊ closure object object ΩϟϓνϟϦετ
 [weak self]

  68. ༨ஊ closure object object ΩϟϓνϟϦετ
 [weak self]

  69. ༨ஊ closure object object

  70. ༨ஊ closure object object

  71. ༨ஊ closure object object

  72. ༨ஊ closure object object

  73. ༨ஊ closure object object

  74. ໰ 1 weak ʹ͢΂͖ʁ strong ʹ͢΂͖ʁ class ViewController: UIViewController {


    @IBOutlet /* weak? strong? */ var label: UILabel! … }
  75. ໰ 1 ͲͪΒ΋Մೳ
 (ঢ়گʹΑΔ͚ΕͲɺ`weak` ͕ద͢Δ৔߹͕ଟ͍) class ViewController: UIViewController {
 @IBOutlet

    /* weak? strong? */ var label: UILabel! … }
  76. ໰ 1 view viewController view sub views strong

  77. ໰ 1 view viewController view sub views weak

  78. ໰ 1 view viewController view sub views weak

  79. ໰ 1 view viewController view sub views weak

  80. ໰ 1 view viewController view sub views strong

  81. ໰ 1 view viewController view sub views strong

  82. ໰ 1 view viewController view sub views strong

  83. ໰ 1 view viewController view sub views strong

  84. ໰ 1 view viewController view sub views weak memory warning

    ൃੜ࣌ʹ
 view Λഁغ͢Δ৔߹͕͋ΔͷͰɺ
 weak ͷํ͕޷౎߹ͳ৔߹͕ଟ͍
  85. ໰ 1 view viewController view sub views strong vc ࣗ਎͕ڧ͘ґଘ͍ͯ͠ΔͳΒɺ


    strong Ͱ΋ྑ͍৔߹΋͋Δ
  86. ໰ 1 view viewController view sub views weak vc.view ͕׬શʹ໋ΛѲΔͳΒ


    weak ͕ద͍ͯ͠Δ
  87. ໰ 1 view viewController view sub views weak vc.view ͕׬શʹ໋ΛѲΔͳΒ


    weak ͕ద͍ͯ͠Δ
  88. ໰ 1 view viewController view sub views weak vc.view ͕׬શʹ໋ΛѲΔͳΒ


    weak ͕ద͍ͯ͠Δ
  89. thread

  90. Thread ͱ͸ʁ

  91. • UIViewController ࡞੒ͯ͠ • ஋Λઃఆͯ͠ • ͦΕΛදࣔ ஋Λઃఆ ViewController 


    ࡞੒ දࣔ
  92. DispatchQueue.main.async { // σʔλΛදࣔ } ஋Λઃఆ ViewController 
 ࡞੒ දࣔ

    • UIViewController ࡞੒ͯ͠ • ஋Λઃఆͯ͠ • ͦΕΛදࣔ • αʔό͔ΒσʔλΛͱ͖ͬͯͯ • σʔλΛදࣔ αʔόͱ௨৴ σʔλΛදࣔ thread thread
  93. thread • thread of execution • single thread (Լਤ) ը૾Λ

    ը໘Λ੾Γସ͑Δ λοϓ͞Εͨ σʔλΛอଘ ड৴଴ͪ μ΢ϯϩʔυ࢝ΊΔ ड৴த εΫϩʔϧ
  94. thread • thread of execution • multi thread (Լਤ) ը૾Λදࣔ͢Δ

    ը໘Λ੾Γସ͑Δ λοϓ͞Εͨ σʔλΛอଘ ड৴଴ͪ μ΢ϯϩʔυ࢝ΊΔ ड৴த εΫϩʔϧ
  95. iOS Ͱͷૢ࡞ • GCD • NSOperation • ௚઀ thread Λѻ͏

    (͋·Γ΍Βͳ͍) • (Rx ͷϝιου౳Ͱࢦఆ) DispatchQueue.global().async { <#code#> }
  96. iOS Ͱͷ thread • main thread • 1 ͚ͭͩ (ΞϓϦىಈ࣌ʹ࡞੒͞ΕΔ)

    • sub thread • ෳ਺ଘࡏՄೳ • ௨৴ॲཧɺDB ૢ࡞౳ͷॏ͍ॲཧ΍ϩάΛૹ৴͢ΔͳͲͷॲཧ
  97. “UI ͷૢ࡞͸ main thread Ͱ΍Ζ͏”

  98. main thread Ҏ֎Ͱ΍ͬͨΒͲ͏ͳΔͷʁ

  99. Ͳ͏͍͏ͱ͖ɺ
 ͦΕΛҧ൓ͯ͠͠·͏ͷʁ

  100. main thread ͬͯɺ
 Կऀʁ

  101. main thread • ΞϓϦىಈ࣌ʹ࡞੒͞ΕΔ • Run loop ͕ճ͍ͬͯΔ • ΠϕϯτΛϋϯυϦϯά

    • λοϓ͞ΕͨͳͲͷ UI Πϕϯτ • ϥΠϑαΠΫϧ (ىಈͨ͠ɺ෮ؼͨ͠ɺ…) • දࣔͷߋ৽ • …
  102. Run loop on main thread Πϕϯτདྷͳ͍͔ͳ

  103. Run loop on main thread Πϕϯτདྷͳ͍͔ͳ

  104. Run loop on main thread Πϕϯτདྷͳ͍͔ͳ λοϓͨ͠ʂ

  105. Run loop on main thread དྷͨʂ
 View ʹ௨஌ͯ͠
 ఆٛ͞Εͯͨಈ࡞Λͯ͠…
 ΠϕϯτͷͨΊͷશͯͷॲཧΛͨ͠Β

  106. Run loop on main thread Πϕϯτདྷͳ͍͔ͳ Πϕϯτདྷͳ͍͔ͳ

  107. ΋͠ɺॏ͍ॲཧΛ main thread Ͱ΍Δͱ ௨৴։࢝ ௨৴଴ͬͯΔ DB ʹอଘ …

  108. ΋͠ɺॏ͍ॲཧΛ main thread Ͱ΍Δͱ ௨৴։࢝ ௨৴଴ͬͯΔ DB ʹอଘ … λοϓͨ͠ʂ

  109. ΋͠ɺॏ͍ॲཧΛ main thread Ͱ΍Δͱ ௨৴։࢝ ௨৴଴ͬͯΔ DB ʹอଘ … λοϓͨ͠ʂ

    ͝ΊΜɺ๩͍͠…
  110. main thread • ΞϓϦىಈ࣌ʹ࡞੒͞ΕΔ • Run loop ͕ճ͍ͬͯΔ • ΠϕϯτΛϋϯυϦϯά

    • λοϓ͞ΕͨͳͲͷ UI Πϕϯτ • ϥΠϑαΠΫϧ (ىಈͨ͠ɺ෮ؼͨ͠ɺ…) • දࣔͷߋ৽ • …
  111. “UI ͷૢ࡞͸ main thread Ͱ΍Ζ͏”

  112. ໰ 1 @IBAction func buttonDidTap(_ sender: UIButton) { label.text =

    "Changed" label.textColor = .red sleep(2) view.backgroundColor = .green } 1.Label ͷ৭ͱςΩετΛมߋ 2.2 ඵؒ sleep 3.എܠ৭Λมߋ
  113. ໰ 1 (౴͑) @IBAction func buttonDidTap(_ sender: UIButton) { label.text

    = "Changed" label.textColor = .red sleep(2) view.backgroundColor = .green } 1. 2 ඵؒ Ϣʔβͷૢ࡞Λड͚෇͚ͳ͍ 2. Label ͱ എܠͷද͕ࣔಉ࣌ʹมΘΔ
  114. Πϕϯτ଴ͪ ը໘ͷߋ৽ λοϓ͞Εͨ = Ϣʔβ༝དྷͷૢ࡞
 λοϓ͞Εͨͱ͖ͷॲཧ (func buttonDidTap) ໰ 1

    (ղઆ) Πϕϯτ଴ͪ main thread
  115. ໰ 2 @IBAction func buttonDidTap(_ sender: UIButton) { DispatchQueue.global().async {

    [label = label] in label?.text = "Changed" label?.textColor = .red } view.backgroundColor = .green } 1.sub thread Ͱ Label Λมߋ 2.main thread ͰഎܠΛมߋ
  116. ໰ 2 (౴͑) @IBAction func buttonDidTap(_ sender: UIButton) { DispatchQueue.global().async

    { [label = label] in label?.text = "Changed" label?.textColor = .red } view.backgroundColor = .green } ෆఆͷಈ࡞
  117. Πϕϯτ଴ͪ
 main loop ը໘ͷߋ৽ λοϓ͞Εͨ = Ϣʔβ༝དྷͷૢ࡞
 λοϓ͞Εͨͱ͖ͷॲཧ (func buttonDidTap)


    view ͷഎܠߋ৽ ໰ 2 (ղઆ) label ͷ text Λมߋ
 label ͷେ͖͞Λߋ৽
 ؔ࿈͢Δ view ͷ഑ஔΛ࠶ܭࢉ
 label ͷ৭Λมߋ
 … main thread sub thread
  118. ໰ 3 override func viewDidLoad() { super.viewDidLoad() NotificationCenter.default .addObserver(forName: .notificationKey,

    object: nil, queue: nil) { _ in // ᶃ } } ᶃ ͸Ͳͷ thread Ͱಈ͘ʁ
  119. ໰ 3 (౴͑) NotificationCenter.default
 ɹɹɹɹɹɹɹ .post(name: .notificationKey,
 ɹɹɹɹɹɹɹɹɹɹɹɹɹ object: nil)


    notification Λൃߦͨ͠ thread
  120. “UI ͷૢ࡞͸ main thread Ͱ΍Ζ͏”

  121. main thread Ҏ֎Ͱ΍ͬͨΒͲ͏ͳΔͷʁ ෆఆͷಈ࡞
 Ϋϥογϡ͢ΔՄೳੑ΋͋Δ

  122. Ͳ͏͍͏ͱ͖ɺ
 ͦΕΛҧ൓ͯ͠͠·͏ͷʁ sub thread Ͱ UI Λૢ࡞͢ΔॲཧΛ࣮ߦͨ͠ͱ͖
 * UI Λૢ࡞͢ΔॲཧΛؚΜͰ͍Δ

    function Λ sub thread Ͱ࣮ߦ
 * UI Λૢ࡞͢ΔॲཧΛؚΉ closure Λ sub thread Ͱ࣮ߦ
 * didSet ౳ʹ UI Λૢ࡞͢ΔॲཧΛؚΜͰ͍ΔϓϩύςΟʹ sub thread Ͱ୅ೖॲཧ࣮ߦ
 * Rx Ͱɺ͍ͭͷؒʹ͔ sub thread Ͱ࣮ߦ͞ΕΔΑ͏ʹͳ͍ͬͯͨ
 ͳͲͳͲ
  123. ๷͙ํ๏͸ʁ • UI ͷૢ࡞ΛؚΉ͜ͱΛ໊લ΍ίϝϯτͰ໌ࣔ͢Δ • sub thread Ͱ࣮ߦ͍ͯͯ͠ɺUI Λૢ࡞ͨ͘͠ͳͬͨΒɺGCD ౳Λ࢖ͬͯ


    main thread Ͱ࣮ߦ͢ΔΑ͏ʹ੍ޚ • Xcode9 Ͱ͸ UI ͷૢ࡞Λ sub thread ্Ͱ࣮ߦ͍ͯ͠Δͱܯࠂͯ͘͠ΕΔػೳ͕ ͋Δ
  124. main thread ͬͯɺ
 Կऀʁ • UI ΠϕϯτͷϋϯυϦϯάͷ໾ׂ • ΞϓϦͷϥΠϑαΠΫϧͷ௨஌ •

    وॏͳϦιʔε (๩͍͠ͱΞϓϦ͕ΧΫͭ͘ݪҼʹͳΔ)
  125. ·ͱΊ • ͋ΘͯͣɺجૅΛ਎ʹ͚ͭΔͱਊ͔Βڧ͘ͳΕΔ • weak, strong ͷ࢖͍෼͚ • ΦϒδΣΫτؒͷؔ܎ੑ͔Βߟ͑ͯΈΑ͏ •

    thread • main thread ্Ͱ UI ૢ࡞ • function ΍ closure ͸ݺͼग़͞Εͨ thread ্Ͱ࣮ߦ͞ΕΔͷΛ
 ೦಄ʹஔ͍ͯɺ࣮ߦ࣌ͷঢ়گΛ૝૾ͯ͠ΈΑ͏
  126. Q&A