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
280
Other Decks in Programming
See All in Programming
良いユニットテストを書こう
mototakatsu
9
3.2k
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
110
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
3
500
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
160
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
4
400
Kaigi on Railsに初参加したら、その日にLT登壇が決定した件について
tama50505
0
110
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
350
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
290
命名をリントする
chiroruxx
1
450
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
280
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
460
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
44
13k
Facilitating Awesome Meetings
lara
50
6.1k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
460
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.4k
Into the Great Unknown - MozCon
thekraken
34
1.5k
What's in a price? How to price your products and services
michaelherold
244
12k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
It's Worth the Effort
3n
183
28k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Building an army of robots
kneath
302
44k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
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() } } શʹཧղͰ͖Δ
͓͠·͍