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
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
Jakarta EE meets AI
ivargrimstad
0
240
HTTP compression in PHP and Symfony apps
dunglas
2
1.7k
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
200
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
270
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
240
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
120
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
130
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
fs2-io を試してたらバグを見つけて直した話
chencmd
0
230
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.6k
たのしいparse.y
ydah
3
120
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
A Tale of Four Properties
chriscoyier
157
23k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
For a Future-Friendly Web
brad_frost
175
9.4k
Building Adaptive Systems
keathley
38
2.3k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Writing Fast Ruby
sferik
628
61k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
How STYLIGHT went responsive
nonsquared
95
5.2k
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() } } શʹཧղͰ͖Δ
͓͠·͍