Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Escaping Closures in Swift - 公司內分享會
Search
Lihsuan Chen
September 23, 2016
Programming
300
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Escaping Closures in Swift - 公司內分享會
Lihsuan Chen
September 23, 2016
Transcript
23 slides
&TDBQJOH$MPTVSFT ꤫խ愴蠩 @escaping
䖰ㆭ酭鷗鷗ㆭ酭
殹DMPTVSF⡲捀侸⫄Ⰵ♧⦐NFUIPE儘 鸏⦐DMPTVSF剚㖈NFUIPE㛂遤㸤䧭䖕 䩞剚鄄㛂遤儘㽠䗳갭䭸㹁䧭FTDBQJOHDMPTVSF
⾲㨥䞕㞯 雊䧮⦛⢵䢩䢩⸈匌銯
class A { func someMethod(closure: () -> Void) { closure()
} } 鸏♧媯♶剚剤DPNQJMFSFSSPS
䞕㞯♧ 鸏⦐DMBTT剤⦐荈㹁纏涸RVFVF ⢵嶋⻋♶ずNFUIPE⫄Ⰵ涸DMPTVSFT
class A { var closures: [() -> Void]? = []
func someMethod(closure: () -> Void) { self.closures?.append(closure) } } 㖈4XJGUⴀ⢵⟃鸏媯♶剚剤㉏겗
class A { var closures: [() -> Void]? = []
func someMethod(closure: () -> Void) { self.closures?.append(closure) } }
None
class A { var closures: [() -> Void]? = []
func someMethod(closure: @escaping () -> Void) { self.closures?.append(closure) } }
㼭穡 • @escaping ˖ ⫄ⰅNFUIPE涸DMPTVSF㥶卓銴㖈NFUIPE GVODUJPO涸SFUVSO䖕䩞㛂遤㽠䗳갭銴⸈♳ @escaping ˖ @noescapeJNQMJDJUMZ ˖
DMPTVSF⡲捀侸갸鏤鿪僽@noescape
䞕㞯✳ 䧮欽痧♲倰MJCSBSZ涸NFUIPE FH"MBNPSF
〫銴➮剤FTDBQJOH ⡹㽠銴騈衽!FTDBQJOH
class B { var closures: [() -> Void]? = []
func anotherMethod(closure: @escaping () -> Void) { self.closures?.append(closure) } }
class A { func someMethod(closure: () -> Void) { B().anotherMethod(closure:
closure) } } class B { var closures: [() -> Void]? = [] func anotherMethod(closure: @escaping () -> Void) { self.closures?.append(closure) } } 㖈4XJGUⴀ⢵⟃鸏垺㻨♶剚剤㉏겗
class A { func someMethod(closure: () -> Void) { B().anotherMethod(closure:
closure) } } class B { var closures: [() -> Void]? = [] func anotherMethod(closure: @escaping () -> Void) { self.closures?.append(closure) } }
None
class A { func someMethod(closure: @escaping () -> Void) {
B().anotherMethod(closure: closure) } } class B { var closures: [() -> Void]? = [] func anotherMethod(closure: @escaping () -> Void) { self.closures?.append(closure) } }
籏穡♧♴
䖰ㆭ酭鷗鷗ㆭ酭
鷗ⴀ㛂遤涸眕㕠
Ⱖ➮ ˖ 〳⟃鍑对SFUBJODZDMF涸㉏겗 4& 䖊㻜뀿 ˖ OPFTDBQFDMPTVSFTIBWFBMTPBMXBZTCFFOUIF QSFGFSSFEEFGBVMU
TJODFUIFZFMJNJOBUFBDMBTT PGSFUBJODZDMFJTTVFT ˖ QSPUPDPM涸㹁纏 ˖ 㥶卓㻜⡲QSPUPDPM涸倰岁儘銴⸈!FTDBQJOH QSPUPDPM⚥鑪倰岁涸㹁纏⛳銴⸈♳
5IBOL:PV
More Decks by Lihsuan Chen
See All by Lihsuan Chen
iPlayground 2025 - 接⼿ 10年⼤雜燴:專案現代化與產品開發的挑戰
vc7
0
240
The UX thinking of PAY ID
vc7
2
520
From Onboarding to Value Delivering in iOS
vc7
0
330
Merciless Refactoring
vc7
0
840
Protocol 的實例、測試和心得
vc7
2
860
共有経済
vc7
0
220
.gitignore
vc7
1
140
Git Workshop 03
vc7
0
160
Git Workshop 02
vc7
0
150
Other Decks in Programming
See All in Programming
Datadog を OTel にするメリットを考察する — Datadog との併用を実アプリで確かめる / Examining the Benefits of Moving Datadog to OTel — Testing OTel Alongside Datadog in a Real App
seike460
PRO
1
110
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
200
imagewebp()の向こう側: WebPはなぜ JPEG・PNGより軽いのか
yuzneri
0
160
仕様駆動開発入門 (何を作るかを先に決めて渡す) | 目指せ Kiro マスター 05
inariku
PRO
3
240
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
850
AIコーディングをセッションで終わらせない: PHPライブラリ開発におけるコンテキスト承継設計
ickx
0
110
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
240
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
190
[DroidKnights 2026] Workflow AX 적용기 — 자동 정책 정리부터 E2E까지
dayeon
0
130
はじめてのPLATEAU
nokonoko1203
1
680
Kiro Crewによる開発体験ーKiro CrewでStrands Decider 2B に関する技術検証をやってみた
satoshi256kbyte
1
220
ビジネスロジックを堅牢に~Scala 3のドメインプリミティブ~
j5ik2o
0
230
Featured
See All Featured
Site-Speed That Sticks
csswizardry
13
1.6k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
370
Tell your own story through comics
letsgokoyo
1
1.1k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Ruling the World: When Life Gets Gamed
codingconduct
0
450
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
How to build a perfect <img>
jonoalderson
1
6.3k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
320
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.8k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
340
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
760