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
970
アプリが動いたその先へ (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.4k
Secret Swift tour
ezura
7
2.8k
Swift Album ver.4.1
ezura
3
1.4k
Swift と Kotlin
ezura
4
2.6k
哲学とSwiftの発表
ezura
5
580
Blending Kotlin's culture into Swift
ezura
1
1.2k
Re: エラーと警告でコードをデザインする
ezura
2
950
Other Decks in Programming
See All in Programming
ドメインイベント増えすぎ問題
h0r15h0
1
120
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
0
160
nekko cloudにおけるProxmox VE利用事例
irumaru
3
420
CSC509 Lecture 14
javiergs
PRO
0
130
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
450
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
1
360
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
あれやってみてー駆動から成長を加速させる / areyattemite-driven
nashiusagi
1
200
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
740
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
140
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
200
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Designing for humans not robots
tammielis
250
25k
Being A Developer After 40
akosma
87
590k
GraphQLとの向き合い方2022年版
quramy
44
13k
Building Applications with DynamoDB
mza
91
6.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
We Have a Design System, Now What?
morganepeng
51
7.3k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
170
Practical Orchestrator
shlominoach
186
10k
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