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
FunctionBuildersから見るSwiftUIの文法
Search
kojiaomatsu
July 12, 2019
Programming
0
150
FunctionBuildersから見るSwiftUIの文法
SwiftUIの文法の難しいところをFunctionBuildersやその他のSwiftの文法から解説しています。
型がどうなっているのかに着目するとジェネリクスのパワフルさが見えて感動します。
kojiaomatsu
July 12, 2019
Tweet
Share
More Decks by kojiaomatsu
See All by kojiaomatsu
2相コミットなどの実例に見るゴルーチンとチャネルの使いどころ
kojiaomatsu
0
270
Other Decks in Programming
See All in Programming
最新TCAキャッチアップ
0si43
0
190
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
210
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
300
subpath importsで始めるモック生活
10tera
0
310
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
890
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
[Do iOS '24] Ship your app on a Friday...and enjoy your weekend!
polpielladev
0
110
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.8k
Featured
See All Featured
Being A Developer After 40
akosma
87
590k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Visualization
eitanlees
145
15k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
130
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Music & Morning Musume
bryan
46
6.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
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() } } શʹཧղͰ͖Δ
͓͠·͍