$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
FunctionBuildersから見るSwiftUIの文法
Search
kojiaomatsu
July 12, 2019
Programming
0
170
FunctionBuildersから見るSwiftUIの文法
SwiftUIの文法の難しいところをFunctionBuildersやその他のSwiftの文法から解説しています。
型がどうなっているのかに着目するとジェネリクスのパワフルさが見えて感動します。
kojiaomatsu
July 12, 2019
Tweet
Share
More Decks by kojiaomatsu
See All by kojiaomatsu
2相コミットなどの実例に見るゴルーチンとチャネルの使いどころ
kojiaomatsu
0
340
Other Decks in Programming
See All in Programming
『実践MLOps』から学ぶ DevOps for ML
nsakki55
2
490
Building AI with AI
inesmontani
PRO
1
420
2025 컴포즈 마법사
jisungbin
0
160
connect-python: convenient protobuf RPC for Python
anuraaga
0
320
関数の挙動書き換える
takatofukui
4
750
DSPy Meetup Tokyo #1 - はじめてのDSPy
masahiro_nishimi
1
110
なぜ強調表示できず ** が表示されるのか — Perlで始まったMarkdownの歴史と日本語文書における課題
kwahiro
12
7.4k
TUIライブラリつくってみた / i-just-make-TUI-library
kazto
1
180
UIデザインに役立つ 2025年の最新CSS / The Latest CSS for UI Design 2025
clockmaker
3
2.2k
TVerのWeb内製化 - 開発スピードと品質を両立させるまでの道のり
techtver
PRO
3
1.3k
dnx で実行できるコマンド、作ってみました
tomohisa
0
120
AIの弱点、やっぱりプログラミングは人間が(も)勉強しよう / YAPC AI and Programming
kishida
13
5.5k
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
174
15k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Embracing the Ebb and Flow
colly
88
4.9k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
The Invisible Side of Design
smashingmag
302
51k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
How to Think Like a Performance Engineer
csswizardry
28
2.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8k
Transcript
4XJGU6*BOE'VODUJPOCVJMEFST ,PKJ"PNBUTV
4XJGU6* ɾએݴతʹ6*ΛߏஙͰ͖Δ ɾ4XJGUʢ/PU0CKFDUJWF$ʣ ɾΠϯλϥΫςΟϒʹ6*ΛσβΠϯ ɾ៉ྷʹॻ͚Δ
struct ContentView: View { var body: some View { VStack(alignment:
.leading) { Text("Turtle Rock") .font(.title) HStack { Text("Joshua Tree National Park") .font(.subheadline) Spacer() Text("California") .font(.subheadline) } } .padding() } } &YBNQMF
$PNQVUFE1SPQFSUJFT ɾHFUUFSTFUUFSͰมΛఆٛ ɾҰߦͩͬͨΒSFUVSOΛলུՄೳ ɾHFU͚ͩͳΒHFUΛলུՄೳ ɾ1SPQFSUZ8SBQQFSJTDPNJOH
// Computed Property var hoge : Int { get {
return 3 } } // Shorter version var hoge : Int { return 3 } // Shortest version var hoge : Int { 3 } // This above explains this part struct ContentView: View { var body: some View { VStack(alignment: .leading) { .. } } } &YBNQMF
None
None
(FOFSJDT ɾܕύϥϝʔλʔΛऔΔ͜ͱ͕ग़དྷΔܕ ɾ"SSBZܕ3FTVMUܕͳͲ
74UBDLͷܕύϥϝʔλʔ 74UBDLͷJOJUؔΛ͍ͯΈΔͱ @ViewBuilder content: () -> Content ͜Εʜ
7JFX#VJMEFSͱ 'VODUJPO#VJMEFSTͱ͍͏Έ͕ΘΕ͍ͯΔ
'VODUJPOCVJMEFST ɾ"UUSJCVUFΛಠࣗఆٛͰ͖Δ ɾϦετߏΛѻ͏ ɾ%4-ΛίϯύΠϥ͕ղੳ
'VODUJPOCVJMEFST @_functionBuilder struct Hoge { static func buildBlock(_ a: Int,
_ b: Int) -> Int { return a + b } } func fuga(@Hoge a: () -> Int) -> Int { return a() } let puni = fuga { 76 33 } print(puni) // 109
74UBDLͷCVJME#MPDL
74UBDLͷCVJME#MPDL ͜ΕʹΑΓͭҎ্ͷཁૉΛ࣋ͭ 74UBDLͷܕύϥϝʔλʔ$POUFOU 5VQMF7JFXʹͳΔ͜ͱ͕Θ͔Δ
HStack { Text("Joshua Tree National Park") Spacer() Text("California") } 4XJGU6*ͷܕΛݟ͍ͯ͘
HStack<TupleView<(Text, Spacer, Text)>> var body: some View { VStack(alignment: .leading) { Text("Turtle Rock") HStack { .. } } } VStack<TupleView<(Text, HStack<TupleView<(Text, Spacer, Text)>>)>>
4XJGU6*ʹ͓͚Δܕ·ͱΊ 7JFXϓϩτίϧʹଋറ͞ΕͨܕύϥϝʔλʔͰ͋Δ $POUFOUΛੜ͢ΔͨΊʹ7JFX#VJMEFSTͷ CVJME#MPDL͕ؔΘΕ͍ͯΔ CVJME#MPDLؔҾ͕͍ͭ͘ೖͬͯ͘Δ͔Θ͔Β ͳ͍ͷͰɺͦΕΛ5VQMF7JFXͳͲͱͯ͠ѻͬͯ (FOFSJD4USVDUVSFΛఆٛ͢Δͷ͕໘ന͍ ੩తʹܕΛܾఆͰ͖ΔͷͰ0QBRVF3FTVMU5ZQFTΛ ͍ͬͯΔ
struct ContentView: View { var body: some View { VStack(alignment:
.leading) { Text("Turtle Rock") .font(.title) HStack { Text("Joshua Tree National Park") .font(.subheadline) Spacer() Text("California") .font(.subheadline) } } .padding() } } શʹཧղͰ͖Δ
͓͠·͍