Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
アプリが動いたその先へ (iOS アプリ開発編)
Search
Yuka Ezura
August 18, 2017
Programming
1
950
アプリが動いたその先へ (iOS アプリ開発編)
Yuka Ezura
August 18, 2017
Tweet
Share
More Decks by Yuka Ezura
See All by Yuka Ezura
Mastering share sheet preview
ezura
4
1.3k
SF Symbols
ezura
9
1.2k
気遣いの iOS プログラミング
ezura
11
3.3k
Secret Swift tour
ezura
7
2.8k
Swift Album ver.4.1
ezura
3
1.4k
Swift と Kotlin
ezura
4
2.5k
哲学とSwiftの発表
ezura
5
570
Blending Kotlin's culture into Swift
ezura
1
1.2k
Re: エラーと警告でコードをデザインする
ezura
2
940
Other Decks in Programming
See All in Programming
色々なIaCツールを実際に触って比較してみる
iriikeita
0
250
外部システム連携先が10を超えるシステムでのアーキテクチャ設計・実装事例
kiwasaki
1
220
Java ジェネリクス入門 2024
nagise
0
600
レガシーな Android アプリのリアーキテクチャ戦略
oidy
1
170
Kotlin2でdataクラスの copyメソッドを禁止する/Data class copy function to have the same visibility as constructor
eichisanden
1
110
Amazon Neptuneで始めてみるグラフDB-OpenSearchによるグラフの全文検索-
satoshi256kbyte
4
310
VR HMDとしてのVision Pro+ゲーム開発について
yasei_no_otoko
0
100
組織に自動テストを書く文化を根付かせる戦略(2024秋版) / Building Automated Test Culture 2024 Autumn Edition
twada
PRO
10
4.5k
C#/.NETのこれまでのふりかえり
tomokusaba
1
150
go.mod、DockerfileやCI設定に分散しがちなGoのバージョンをまとめて管理する / Go Connect #3
arthur1
10
2.3k
PagerDuty を軸にした On-Call 構築と運用課題の解決 / PagerDuty Japan Community Meetup 4
horimislime
1
110
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
1
290
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
51
13k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
It's Worth the Effort
3n
183
27k
Gamification - CAS2011
davidbonilla
80
5k
Fashionably flexible responsive web design (full day workshop)
malarkey
404
65k
Measuring & Analyzing Core Web Vitals
bluesmoon
1
39
Optimising Largest Contentful Paint
csswizardry
33
2.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Happy Clients
brianwarren
97
6.7k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
Statistics for Hackers
jakevdp
796
220k
Transcript
ΞϓϦ͕ಈ͍ͨͦͷઌ (iOS ΞϓϦ։ൃฤ) 2017/8/18 ezura
“\(self)” • iOS engineer @ LINE • ֶੜ࣌: Android, iOS
engineer • Swift, Objective-C, Kotlin, Java, … ezura (@eduraaa)
୭ͩͬͯ࠷ॳॳ৺ऀ
ίʔυΛͬͯష͚ͬͯͬͭͯͨ͘Βɺ ΞϓϦ͕Ͱ͖͍ͯͨ ( 'ω')
Α͘Θ͔Βͳ͍ͱ͜Ζ͋Δ͚Ͳɺ ΞϓϦ͕Ͱ͖͍ͯͨ ( 'ω') retain…, delegate…, tableView…, ฒྻॲཧ…
ͳΜ͔ϝϞϦϦʔΫ͚ͯͨ͠Ͳɺ ΞϓϦ͕Ͱ͖͍ͯͨ ( 'ω') ࠭ͷ͓ͷΑ͏ͳίʔυ…
ϓϩͱͯ͠ஏ͔ͣ͘͠ͳ͍ɺ ΞϓϦΛ࡞Γ͍ͨ ( 'ω') Ͳ͏͢Εྑ͍ΜͩΖ͏…
ॳ৺ऀͷͱ͖ٙͩͬͨ͜ͱɺΜͰͨ͜ͱ Α͘ฉ࣭͘ weak ͱ strong ͷ͍͚ thread ཧͬͯ ݁ہͲ͏͢Εྑ͍ͷʁ งғؾͰ
thread Λ ͍ͬͯΔ ॥ࢀরා͍ Ͳ͏͢Ε͛Δͷʁ ࣗͷϓϩάϥϜͷ࣭ͬͯ ࣮ࡍʹͲͷϨϕϧͳͷ… ຊμϝͳ͜ͱΛ ͍ͬͯΔͷͰ… storyboard ͬͨํ͕ྑ͍ͷʁ
ݪଇɾݪཧ (جૅ) ঢ়گ + = ͑
ࠜຊతͳ෦Λ͓͞Β͍͠ͳ͕Β ٙΛղܾ͍ͯ͜͠͏ త
index • ࢀরपΓ • thread पΓ • ͦͷଞͷ͜ͱͰ࣭ɾ૬ஊ
ࢀরɾϝϞϦपΓ
॥ࢀরΛͲ͏͛ྑ͍ͷʁ
weak ͱ strong ͷ͍͚ʁ
ͦͦɺstrong ͱ͔ weak ͷࢦఆ ͳͥඞཁʁʁ
ΦϒδΣΫτΛ࡞Δ ↓ ΦϒδΣΫτͷσʔλΛஔ͍͓ͯ͘ॴ͕ඞཁ ↓ ΦϒδΣΫτͷσʔλΛஔ͍͓ͯ͘ॴΛϝϞϦ্ʹ֬อ͓ͯ͘͠ object
ΦϒδΣΫτΛ࡞Δ ↓ ΦϒδΣΫτͷσʔλΛஔ͍͓ͯ͘ॴ͕ඞཁ ↓ ΦϒδΣΫτͷσʔλΛஔ͍͓ͯ͘ॴΛϝϞϦ্ʹ֬อ͓ͯ͘͠ memory object
ΦϒδΣΫτΛ࡞Δ ↓ ΦϒδΣΫτͷσʔλΛஔ͍͓ͯ͘ॴ͕ඞཁ ↓ ΦϒδΣΫτͷσʔλΛஔ͍͓ͯ͘ॴΛϝϞϦ্ʹ֬อ͓ͯ͘͠ object memory
͍ͭɺ֬อͨ͠ྖҬΛղ์͢Εྑ͍ʁʁ object memory
͍ͭɺ֬อͨ͠ϝϞϦΛղ์͢Εྑ͍ʁʁ object memory object object ͏ೖΒͳ͍… མͪΑ…( ˘ω˘) object
object memory object object ͏ೖΒͳ͍… མͪΑ…( ˘ω˘) ͍ͭɺ֬อͨ͠ϝϞϦΛղ์͢Εྑ͍ʁʁ ↓ ΦϒδΣΫτ͕ෆཁʹͳͬͨͱ͖
object
“ཁΒͳ͍” ͬͯɺͲ͏ͬͯஅ͢Εྑ͍ʁ
ϝϞϦͷཧ • Java, Ruby, JavaScript, … • ํ๏: Garbage Collection
• Ͳ͔͜Βࢀর͞Εͳ͘ͳͬͨΦϒδΣΫτΛ GC ͕ௐͯղ์ (ਓ͕ཧ͠ͳ͍) • Swift, Objective-C • ํ๏: Reference Counting • ඞཁͳΒΧϯτΛ૿͠ɺཁΒͳ͘ͳͬͨΒΧϯτΛݮΒ͢ Χϯτ͕ 0 ʹͳͬͨΒෆཁͱΈͳͯ͠ղ์ (Reference Count = ΦϒδΣΫτΛඞཁͱ͍ͯ͠Δͷ)
Reference Counting • Swift, Objective-C • ARC (Automatic Reference Counting)
• weak ࢀরͱ strong ࢀর • Objective-C (ੲ) • MRC (Manual Reference Counting) • [obj retain] ͱ͔ॻ͍ͯ͋ͬͨΒ͜Ε
Reference Counting • Swift, Objective-C • ARC (Automatic Reference Counting)
• weak ࢀরͱ strong ࢀর • Objective-C (ੲ) • MRC (Manual Reference Counting) • [obj retain] ͱ͔ॻ͍ͯ͋ͬͨΒ͜Ε
Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ object
Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม͕͋Γ·͢ object strong let
obj = object ࢀরΧϯτ += 1 => 1
Reference Count object strong let obj = object ࢀরΧϯτ -=
1 => 0 • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม͕͋Γ·͢ • strong ࢀর͍ͯ͠Δม͕ͳ͘ͳΓ·ͨ͠
Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม͕͋Γ·͢ • strong ࢀর͍ͯ͠Δม͕ͳ͘ͳΓ·ͨ͠
• ΦϒδΣΫτղ์͞Ε·͢ object strong let obj = object ࢀরΧϯτ => 0
Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ object
Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม͕͋Γ·͢ object strong let
obj = object ࢀরΧϯτ += 1 => 1
Reference Count object strong let obj = object ࢀরΧϯτ
=> 1 weak var obj = object • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม͕͋Γ·͢
Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม͕͋Γ·͢
• weak ࢀর͍ͯ͠Δม͕ͳ͘ͳΓ·ͨ͠ object strong let obj = object ࢀরΧϯτ => 1 weak var obj = object
Reference Count • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม͕͋Γ·͢
• weak ࢀর͍ͯ͠Δม͕ͳ͘ͳΓ·ͨ͠ object strong let obj = object ࢀরΧϯτ => 1
Reference Count object strong let obj = object ࢀরΧϯτ +=
1 => 1 weak var obj = object • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม͕͋Γ·͢
Reference Count object strong let obj = object ࢀরΧϯτ -=
1 => 0 weak var obj = object • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม͕͋Γ·͢ • strong ࢀর͍ͯ͠Δม͕ͳ͘ͳΓ·ͨ͠
Reference Count object strong let obj = object ࢀরΧϯτ =>
0 weak var obj = object • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม͕͋Γ·͢ • strong ࢀর͍ͯ͠Δม͕ͳ͘ͳΓ·ͨ͠ • ΦϒδΣΫτղ์͞Ε·͢
Reference Count object strong let obj = object ࢀরΧϯτ =>
0 weak var obj = object • ΦϒδΣΫτΛ࡞Γ·ͨ͠ • strong ࢀর͍ͯ͠Δม͕͋Γ·͢ • weak ࢀর͍ͯ͠Δม͕͋Γ·͢ • strong ࢀর͍ͯ͠Δม͕ͳ͘ͳΓ·ͨ͠ • ΦϒδΣΫτղ์͞Ε·͢ : nil ͕ೖ͞ΕΔΘ͚Ͱͳ͍
ࢀর strong var obj objA strong var obj objB
ࢀর strong var obj = objB objA strong var obj
= objA objB
ࢀর strong var obj = objB objA strong var obj
= objA objB
ࢀর strong var obj = objB objA strong var obj
= objA objB ॥ࢀর
ࢀর strong var obj = objB objA strong var obj
= objA objB Ͳ͏ͨ͠Βղ์͞ΕΔʁ
ࢀর strong var obj = nil objA strong var obj
= objA objB ໌ࣔతʹࢀরΛղ͘ඞཁ͕͋Δ
ࢀর strong var obj = nil objA strong var obj
= objA objB Auto ͱҰମ… :(
ࢀর strong var obj = nil objA strong var obj
= objA objB ʮͺͬͱݟΘ͔Βͳ͍͚Ͳɺ~͠ͳ͍ͱ͍͚ͳ͍ʯ ͷΑ͏ͳɺ҉తྃղͷ͋Δίʔυ͍͔ͭഁ໓͢Δ
ࢀর strong var obj = objB objA strong var obj
= objA objB
ࢀর strong var obj = objB objA weak var obj
= objA objB
ࢀর strong var obj = objB objA weak var obj
= objA objB
ࢀর strong var obj = objB objA weak var obj
= objA objB
ࢀর strong var obj = objB objA weak var obj
= objA objB
ཧతʹΘ͔͚ͬͨͲɺ Ͳ͏͍͚Εྑ͍ͷʁ Object ؒͷؔੑ͔ΒܾΊΑ͏
ࢀর strong var obj = objB objA weak var obj
= objA objB
ParentViewController ChildViewController strong var cvc = cvc weak var delegate
= ChildViewController pvc ParentViewController
ParentViewController ChildViewController strong var cvc = cvc weak var delegate
= ChildViewController pvc ParentViewController
ParentViewController ChildViewController strong var cvc = cvc weak var delegate
= ChildViewController pvc ParentViewController
ParentViewController ChildViewController strong var cvc = cvc weak var delegate
= ChildViewController pvc ParentViewController
ParentViewController ChildViewController strong var cvc = cvc weak var delegate
= ChildViewController pvc ParentViewController
ParentViewController ChildViewController strong var cvc = cvc weak var delegate
= ChildViewController pvc ParentViewController ParentViewController ͕͍ͳ͘ͳͬͨΒɺ ChildViewController ͍Βͳ͘ͳΔؔ
weak ͱ strong ͷ͍͚ʁ Object ؒͷؔੑ͔ΒܾΊΑ͏
॥ࢀরΛͲ͏͛ྑ͍ͷʁ લड़ͷ weak, strong ͷ͍͚ closure ʹΑΔΩϟϓνϟʹؾΛ͚ͭΔ
ࢀর strong var obj = objB objA strong var obj
= objA objB
ࢀর object closure object
ࢀর closure object object
ࢀর closure object object ΩϟϓνϟϦετ [weak self]
༨ஊ closure object object ΩϟϓνϟϦετ [weak self]
༨ஊ closure object object ΩϟϓνϟϦετ [weak self]
༨ஊ closure object object ΩϟϓνϟϦετ [weak self]
༨ஊ closure object object
༨ஊ closure object object
༨ஊ closure object object
༨ஊ closure object object
༨ஊ closure object object
1 weak ʹ͖͢ʁ strong ʹ͖͢ʁ class ViewController: UIViewController {
@IBOutlet /* weak? strong? */ var label: UILabel! … }
1 ͲͪΒՄೳ (ঢ়گʹΑΔ͚ΕͲɺ`weak` ͕ద͢Δ߹͕ଟ͍) class ViewController: UIViewController { @IBOutlet
/* weak? strong? */ var label: UILabel! … }
1 view viewController view sub views strong
1 view viewController view sub views weak
1 view viewController view sub views weak
1 view viewController view sub views weak
1 view viewController view sub views strong
1 view viewController view sub views strong
1 view viewController view sub views strong
1 view viewController view sub views strong
1 view viewController view sub views weak memory warning
ൃੜ࣌ʹ view Λഁغ͢Δ߹͕͋ΔͷͰɺ weak ͷํ͕߹ͳ߹͕ଟ͍
1 view viewController view sub views strong vc ͕ࣗڧ͘ґଘ͍ͯ͠ΔͳΒɺ
strong Ͱྑ͍߹͋Δ
1 view viewController view sub views weak vc.view ͕શʹ໋ΛѲΔͳΒ
weak ͕ద͍ͯ͠Δ
1 view viewController view sub views weak vc.view ͕શʹ໋ΛѲΔͳΒ
weak ͕ద͍ͯ͠Δ
1 view viewController view sub views weak vc.view ͕શʹ໋ΛѲΔͳΒ
weak ͕ద͍ͯ͠Δ
thread
Thread ͱʁ
• UIViewController ࡞ͯ͠ • Λઃఆͯ͠ • ͦΕΛදࣔ Λઃఆ ViewController
࡞ දࣔ
DispatchQueue.main.async { // σʔλΛදࣔ } Λઃఆ ViewController ࡞ දࣔ
• UIViewController ࡞ͯ͠ • Λઃఆͯ͠ • ͦΕΛදࣔ • αʔό͔ΒσʔλΛͱ͖ͬͯͯ • σʔλΛදࣔ αʔόͱ௨৴ σʔλΛදࣔ thread thread
thread • thread of execution • single thread (Լਤ) ը૾Λ
ը໘ΛΓସ͑Δ λοϓ͞Εͨ σʔλΛอଘ ड৴ͪ μϯϩʔυ࢝ΊΔ ड৴த εΫϩʔϧ
thread • thread of execution • multi thread (Լਤ) ը૾Λදࣔ͢Δ
ը໘ΛΓସ͑Δ λοϓ͞Εͨ σʔλΛอଘ ड৴ͪ μϯϩʔυ࢝ΊΔ ड৴த εΫϩʔϧ
iOS Ͱͷૢ࡞ • GCD • NSOperation • thread Λѻ͏
(͋·ΓΒͳ͍) • (Rx ͷϝιουͰࢦఆ) DispatchQueue.global().async { <#code#> }
iOS Ͱͷ thread • main thread • 1 ͚ͭͩ (ΞϓϦىಈ࣌ʹ࡞͞ΕΔ)
• sub thread • ෳଘࡏՄೳ • ௨৴ॲཧɺDB ૢ࡞ͷॏ͍ॲཧϩάΛૹ৴͢ΔͳͲͷॲཧ
“UI ͷૢ࡞ main thread ͰΖ͏”
main thread Ҏ֎ͰͬͨΒͲ͏ͳΔͷʁ
Ͳ͏͍͏ͱ͖ɺ ͦΕΛҧͯ͠͠·͏ͷʁ
main thread ͬͯɺ Կऀʁ
main thread • ΞϓϦىಈ࣌ʹ࡞͞ΕΔ • Run loop ͕ճ͍ͬͯΔ • ΠϕϯτΛϋϯυϦϯά
• λοϓ͞ΕͨͳͲͷ UI Πϕϯτ • ϥΠϑαΠΫϧ (ىಈͨ͠ɺ෮ؼͨ͠ɺ…) • දࣔͷߋ৽ • …
Run loop on main thread Πϕϯτདྷͳ͍͔ͳ
Run loop on main thread Πϕϯτདྷͳ͍͔ͳ
Run loop on main thread Πϕϯτདྷͳ͍͔ͳ λοϓͨ͠ʂ
Run loop on main thread དྷͨʂ View ʹ௨ͯ͠ ఆٛ͞Εͯͨಈ࡞Λͯ͠… ΠϕϯτͷͨΊͷશͯͷॲཧΛͨ͠Β
Run loop on main thread Πϕϯτདྷͳ͍͔ͳ Πϕϯτདྷͳ͍͔ͳ
͠ɺॏ͍ॲཧΛ main thread ͰΔͱ ௨৴։࢝ ௨৴ͬͯΔ DB ʹอଘ …
͠ɺॏ͍ॲཧΛ main thread ͰΔͱ ௨৴։࢝ ௨৴ͬͯΔ DB ʹอଘ … λοϓͨ͠ʂ
͠ɺॏ͍ॲཧΛ main thread ͰΔͱ ௨৴։࢝ ௨৴ͬͯΔ DB ʹอଘ … λοϓͨ͠ʂ
͝ΊΜɺ͍͠…
main thread • ΞϓϦىಈ࣌ʹ࡞͞ΕΔ • Run loop ͕ճ͍ͬͯΔ • ΠϕϯτΛϋϯυϦϯά
• λοϓ͞ΕͨͳͲͷ UI Πϕϯτ • ϥΠϑαΠΫϧ (ىಈͨ͠ɺ෮ؼͨ͠ɺ…) • දࣔͷߋ৽ • …
“UI ͷૢ࡞ main thread ͰΖ͏”
1 @IBAction func buttonDidTap(_ sender: UIButton) { label.text =
"Changed" label.textColor = .red sleep(2) view.backgroundColor = .green } 1.Label ͷ৭ͱςΩετΛมߋ 2.2 ඵؒ sleep 3.എܠ৭Λมߋ
1 (͑) @IBAction func buttonDidTap(_ sender: UIButton) { label.text
= "Changed" label.textColor = .red sleep(2) view.backgroundColor = .green } 1. 2 ඵؒ Ϣʔβͷૢ࡞Λड͚͚ͳ͍ 2. Label ͱ എܠͷද͕ࣔಉ࣌ʹมΘΔ
Πϕϯτͪ ը໘ͷߋ৽ λοϓ͞Εͨ = Ϣʔβ༝དྷͷૢ࡞ λοϓ͞Εͨͱ͖ͷॲཧ (func buttonDidTap) 1
(ղઆ) Πϕϯτͪ main thread
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 ͰഎܠΛมߋ
2 (͑) @IBAction func buttonDidTap(_ sender: UIButton) { DispatchQueue.global().async
{ [label = label] in label?.text = "Changed" label?.textColor = .red } view.backgroundColor = .green } ෆఆͷಈ࡞
Πϕϯτͪ main loop ը໘ͷߋ৽ λοϓ͞Εͨ = Ϣʔβ༝དྷͷૢ࡞ λοϓ͞Εͨͱ͖ͷॲཧ (func buttonDidTap)
view ͷഎܠߋ৽ 2 (ղઆ) label ͷ text Λมߋ label ͷେ͖͞Λߋ৽ ؔ࿈͢Δ view ͷஔΛ࠶ܭࢉ label ͷ৭Λมߋ … main thread sub thread
3 override func viewDidLoad() { super.viewDidLoad() NotificationCenter.default .addObserver(forName: .notificationKey,
object: nil, queue: nil) { _ in // ᶃ } } ᶃ Ͳͷ thread Ͱಈ͘ʁ
3 (͑) NotificationCenter.default ɹɹɹɹɹɹɹ .post(name: .notificationKey, ɹɹɹɹɹɹɹɹɹɹɹɹɹ object: nil)
notification Λൃߦͨ͠ thread
“UI ͷૢ࡞ main thread ͰΖ͏”
main thread Ҏ֎ͰͬͨΒͲ͏ͳΔͷʁ ෆఆͷಈ࡞ Ϋϥογϡ͢ΔՄೳੑ͋Δ
Ͳ͏͍͏ͱ͖ɺ ͦΕΛҧͯ͠͠·͏ͷʁ sub thread Ͱ UI Λૢ࡞͢ΔॲཧΛ࣮ߦͨ͠ͱ͖ * UI Λૢ࡞͢ΔॲཧΛؚΜͰ͍Δ
function Λ sub thread Ͱ࣮ߦ * UI Λૢ࡞͢ΔॲཧΛؚΉ closure Λ sub thread Ͱ࣮ߦ * didSet ʹ UI Λૢ࡞͢ΔॲཧΛؚΜͰ͍ΔϓϩύςΟʹ sub thread Ͱೖॲཧ࣮ߦ * Rx Ͱɺ͍ͭͷؒʹ͔ sub thread Ͱ࣮ߦ͞ΕΔΑ͏ʹͳ͍ͬͯͨ ͳͲͳͲ
͙ํ๏ʁ • UI ͷૢ࡞ΛؚΉ͜ͱΛ໊લίϝϯτͰ໌ࣔ͢Δ • sub thread Ͱ࣮ߦ͍ͯͯ͠ɺUI Λૢ࡞ͨ͘͠ͳͬͨΒɺGCD Λͬͯ
main thread Ͱ࣮ߦ͢ΔΑ͏ʹ੍ޚ • Xcode9 Ͱ UI ͷૢ࡞Λ sub thread ্Ͱ࣮ߦ͍ͯ͠Δͱܯࠂͯ͘͠ΕΔػೳ͕ ͋Δ
main thread ͬͯɺ Կऀʁ • UI ΠϕϯτͷϋϯυϦϯάͷׂ • ΞϓϦͷϥΠϑαΠΫϧͷ௨ •
وॏͳϦιʔε (͍͠ͱΞϓϦ͕ΧΫͭ͘ݪҼʹͳΔ)
·ͱΊ • ͋ΘͯͣɺجૅΛʹ͚ͭΔͱਊ͔Βڧ͘ͳΕΔ • weak, strong ͷ͍͚ • ΦϒδΣΫτؒͷؔੑ͔Βߟ͑ͯΈΑ͏ •
thread • main thread ্Ͱ UI ૢ࡞ • function closure ݺͼग़͞Εͨ thread ্Ͱ࣮ߦ͞ΕΔͷΛ ೦಄ʹஔ͍ͯɺ࣮ߦ࣌ͷঢ়گΛ૾ͯ͠ΈΑ͏
Q&A