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
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
290
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.5k
cmp.Or に感動した
otakakot
2
150
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
210
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
Quine, Polyglot, 良いコード
qnighy
4
640
Better Code Design in PHP
afilina
PRO
0
120
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
CSC509 Lecture 11
javiergs
PRO
0
180
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
For a Future-Friendly Web
brad_frost
175
9.4k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Automating Front-end Workflow
addyosmani
1366
200k
Being A Developer After 40
akosma
86
590k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Gamification - CAS2011
davidbonilla
80
5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
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() } } શʹཧղͰ͖Δ
͓͠·͍