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
Swiftで作るiOSアプリ開発入門_04
Search
jollyjoester
February 27, 2016
Education
0
77
Swiftで作るiOSアプリ開発入門_04
Schoo講義資料
jollyjoester
February 27, 2016
Tweet
Share
More Decks by jollyjoester
See All by jollyjoester
コミュニティMTG in WWDC24
jollyjoester
0
210
BengaluruでLTしてきた
jollyjoester
0
260
try! Swift Tokyo 2024
jollyjoester
0
220
エンジニアが直接会う場の価値について
jollyjoester
8
4k
来年Proposalを出すつもりで参加するときっともっと楽しい!
jollyjoester
0
280
My favorite sessions in WWDC 23
jollyjoester
0
570
みんなでAIと戯れよう
jollyjoester
0
97
続く勉強会の作り方
jollyjoester
2
800
Code for INZAIの歩み
jollyjoester
0
350
Other Decks in Education
See All in Education
技術を楽しもう/enjoy_engineering
studio_graph
1
420
Chapitre_1_-__L_atmosphère_et_la_vie_-_Partie_2.pdf
bernhardsvt
0
200
20241004_Microsoft認定資格のFundamentals全部取ってみた
ponponmikankan
2
330
勉強する必要ある?
mineo_matsuya
2
1.6k
ルクソールとツタンカーメン
masakamayama
1
830
Amazon Connectを利用したCloudWatch Alarm電話通知
junghyeonjae
0
260
小学生にスクラムを試してみた件~中学受検までの100週間の舞台裏~
ukky86
0
340
MLH Hackcon: Keynote (2024)
theycallmeswift
0
180
寺沢拓敬 2024. 09. 「言語政策研究と教育政策研究の狭間で英語教育政策を考える」
terasawat
0
200
CSS3 and Responsive Web Design - Lecture 5 - Web Technologies (1019888BNR)
signer
PRO
1
2.5k
HP用_松尾研紹介資料.pdf
matsuolab
0
170
LLMs for Social Simulation: Progress, Opportunities and Challenges
wingnus
1
100
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
33
2.9k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Bash Introduction
62gerente
608
210k
A Philosophy of Restraint
colly
203
16k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Automating Front-end Workflow
addyosmani
1366
200k
For a Future-Friendly Web
brad_frost
175
9.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
How to Ace a Technical Interview
jacobian
276
23k
Code Reviewing Like a Champion
maltzj
520
39k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Transcript
SwiftͰ࡞Δ iOSΞϓϦ։ൃೖ ̐ݶɿΞϓϦͷϓϩάϥϛϯάʹ༻͍ΔSwiftΛֶͿ 1
ࣗݾհ ࣣౡҒ೭ʢͳͳ͠·ͻͰΏ͖ʣ Reproגࣜձࣾ iPhoneΞϓϦ։ൃ͕͖ 2
ࣗݾհ 3 https://repro.io
ຊίʔεͷඪ ۤΛΓӽ͑ͯ ָ͘͠ΞϓϦ։ൃͰ͖ΔΑ͏ʹͳΔʂ 4
෭ڭࡐ վగ൛ No.1εΫʔϧߨࢣਞʹΑΔ ੈքҰड͚͍ͨ iPhoneΞϓϦ։ൃͷतۀ (ٕज़ධࣾ) 5
ࠓճͷतۀͷඪ Swiftͱྑ͘ͳΔʂ ྑ͘ͳΔͷ͕͍͠ ʮܕʯ ʹ͍ͭͯΛத৺ʹ 6
तۀͷલఏ݅ • ͓खݩͷMacʹXcode(version7.0Ҏ্)͕Πϯετʔ ϧ͞Ε͍ͯΔ͜ͱ 7
ຊͷϝχϡʔ • Swiftʹ͍ͭͯΔ • Playgroundͷ͍ํ • Swiftͷجຊ 8
ͦͷલʹલճͷ࣭͝ ʢAutoLayoutͰΞϓϦͷݟͨΛ͑Δʣ • ʮconstrain to marginsͷON/OFFঢ়ଶΛޙ͔Β֬ೝ͢Δʹ ɺͲ͏͢Ε͍͍Ͱ͔͢ʁʯ from ล ढ़͞Μ
‣ Relative to marginͷઃఆΛ֬ೝ͠·͢ɻ • ʮiPhone͝ͱͷϑΥϯταΠζΛม͍͑ͨ߹Ͳ͏ͨ͠ Βྑ͍ͷͰ͠ΐ͏͔ɻʯ from લా ܒ͞Μ ‣ AutoshrinkΛ͏ͱͰ͖ͦ͏Ͱ͢ɻ 9
Έͳ͞·࣭͋Γ·ͨ͠Βͥͻ࣭͍ͩ͘͝͞ɻ तۀதʹऔΓ্͛ΒΕͳͯ͘ ग़དྷΔݶΓ͓͑͠·͢ʂ ͳΔ΄ͲʂͱࢥͬͨΒʮͳΔ΄ͲʯϘλϯΛ ԡ͍͚ͯͨͩ͠ΔͱྭΈʹͳΓ·͢(`ŋωŋ´) 10
Swiftʹ͍ͭͯΔ 11
Swiftొ 20146݄2 WWDC ↓ ৽͍͠ϓϩάϥϛϯάݴޠͱͯ͠ ҟྫͳ΄ͲٸʹΛूΊΔʂ 12
Swiftొ 20146݄2 WWDC ↓ ৽͍͠ϓϩάϥϛϯάݴޠͱͯ͠ ҟྫͳ΄ͲٸʹΛूΊΔʂ 13
Swiftͷಛ • Ϟμϯ • ҆શ • ΠϯλϥΫςΟϒ 14
Swiftͷಛ • Ϟμϯ ‣ ৽͍͠ػೳʢΦϓγϣφϧͳͲʣ ‣ ৽͍͠ελΠϧʢจίϩϯͳ͠ͳͲʣ • ҆શ •
ΠϯλϥΫςΟϒ 15
Swiftͷಛ • Ϟμϯ • ҆શ ‣ ܕνΣοΫ ‣ ෆ۩߹Λى͜͠ʹ͍͘จ๏ •
ΠϯλϥΫςΟϒ 16
Swiftͷಛ • Ϟμϯ • ҆શ • ΠϯλϥΫςΟϒ ‣ ॻ͍ͨͦͷͰ࣮ߦͰ͖ͨΓ͢Δ ‣
Playground 17
Swiftͷྺ࢙ 18 ొ݄ όʔδϣϯ ରԠXcode 2014/09 1.0 6.0 2014/10 1.1
6.1 2015/04 1.2 6.3.1 2015/09 2.0 7.0 2015/10 2.1 7.1 2015/12 2.2 7.2 2016/06 2.3 8.0 2016/09 3.0 8.0
Swiftҙ όʔδϣϯʹΑͬͯॻ͖ํ͕มΘΔʂ • Xcodeͷόʔδϣϯͷҧ͍ʹҙʂ • Webॻ੶͔ΒใΛ୳͢ͱ͖όʔ δϣϯʹҙ 19
Swiftҙ όʔδϣϯʹΑͬͯॻ͖ํ͕มΘΔʂ • Xcodeͷόʔδϣϯͷҧ͍ʹҙʂ ‣ ৗʹ࠷৽ͷXcodeΛ͏ͱ٢ ‣ ίʔυΛमਖ਼͢Δඞཁ͕͋Δͱ֮ޛ͢Δ ʢΉ͠ΖษڧʹͳΔͱتͿʣ •
Webॻ੶͔ΒใΛ୳͢ͱ͖όʔδϣϯʹ ҙ 20
Swiftҙ όʔδϣϯʹΑͬͯॻ͖ํ͕มΘΔʂ • Xcodeͷόʔδϣϯͷҧ͍ʹҙʂ • Webॻ੶͔ΒใΛ୳͢ͱ͖όʔδϣϯʹҙ ‣ ݕࡧ͢Δͱ͖ʹόʔδϣϯೖΕΔ ʢex. touchesBegan
Swift 2.2ʣ ‣ ॻ੶৽ͳ͏ͪʹফԽ͢Δʂ ʢੈքҰຊมߋ͕͋ͬͨΒग़൛ࣾͷ͍߹Θͤϖʔ δʹܝࡌ͍ͯ͠Δʣ 21
Playgroundͷ͍ํ 22
Playgroundͱ 23 Playground = ༡ͼ SwiftΛͦͷͰॻ͍࣮ͯߦͰ͖Δ
Playground࡞ ʢϝχϡʔ͔Β࡞ʣ 24
Playground࡞ ʢPlayground໊ΛܾΊΔʣ 25
Playground࡞ ʢอଘઌΛܾΊΔʣ 26
Playground࡞ ʢ࡞ྃʣ 27
Playground 28
Playground 29
Playground 30
Swiftͷجຊ 31
ͲΜͳϓϩάϥϛϯάݴޠΛͬͨ͜ͱ͕͋Γ·͔͢ ॳΊͯͷํॳΊͯͱ͓͍͑ͩ͘͞ʂ 32 ࣭Ͱ͢ʂ
ίϝϯτ 33 • ϓϩάϥϜͱͯ͠ղऍ͞Εͳ͍෦ • ਓ͕ؒಡΉ༻ͷ༰Λॻ͖
import 34 • ಛघͳػೳΛ࣋ͬͨframeworkͱ͍͏ͷΛ͏ͨ Ίͷɻޙʑ͍Ζ͍Ζग़ͯ͘Δɻ ʢԼهUIKit.frameworkΛ͏ͨΊͷهड़ɻࠓճ ಛʹΘͳ͍ʣ
มɺೖɺจࣈྻ 35 • มʹΛೖΕͯɺͦΕʹ͍Ζ͍ΖॲཧΛ͢Δ͜ ͱͰϓϩάϥϜ͍ͯ͘͠ ᶃ ͜Ε͔Βstrͱ͍͏໊લͷมΛ͍·͢ ᶄ strʹ”Hello, Swift”ͱ͍͏Λೖ͠·͢
ᶅ ݁Ռstr”Hello, Swift”ͱ͍͏ʹͳ͍ͬͯ·͢
มɺೖɺจࣈྻ 36 • એݴͨ͠มޙ͔Β͑Δ • ೖͯ͠Λมߋ͢Δ͜ͱͰ͖Δ • μϒϧΫΥʔςʔγϣϯͰғ·ΕͨͷΛจࣈྻ ͱ͍͏
ࣈΛೖ 37 • ࣈΛೖ͠Α͏ͱ͢ΔͱΤϥʔ ʢStringܕͷมʹIntܕͷΛׂΓͯΔ͜ͱͰ͖·ͤΜʣ
มʹܕ͕͋Δ 38 • ࠷ॳʹೖͨ͠ʹΑͬͯࣗಈతʹܕ͕ܾ·Δ ʢܕਪʣ • ผͷܕೖ͠Α͏ͱ͢ΔͱΤϥʔʹͳΔ
جຊతͳܕ 39 • String ʢจࣈྻʣ • Intɹɹʢʣ • Doubleʢখʣ •
Boolɹʢਅِʣ
ܭࢉͯ͠ΈΔ 40 • ܕ͕ಉ͡ͷಉ࢜ܭࢉͰ͖Δ
ܭࢉͯ͠ΈΔ 41 • ܕ͕ҧ͏ͷಉ࢜ܭࢉͰ͖ͳ͍ ʢStringͱIntʹ+ԋࢉࢠద༻Ͱ͖·ͤΜʣ ʢIntͱDoubleʹ+ԋࢉࢠద༻Ͱ͖·ͤΜʣ
ܕΛม͢Δ 42 • ܕ͕ಉ͡ͷಉ࢜ܭࢉͰ͖Δ
ԿͰܕมͰ͖Δʁ 43 • ಛघͳ݅Ͱͳ͍ͱมͰ͖ͳ͍ʂ • มʹࣦഊ͢ΔͱʮnilʯʹͳΔ • ࣦഊ͢ΔՄೳ͕͋Δͱ͖ΦϓγϣφϧܕʹͳΔ ʢΦϓγϣφϧܕͷInt?Ξϯϥοϓ͞Εͯ·ͤΜʣ
Φϓγϣφϧܕ 44 • Int?ΛΞϯϥοϓʢதΛऔΓग़͢ʣ͢Δͱ ‣ த͕͋ͬͨΒInt͕ग़ͯ͘Δ ‣ த͕ͳ͔ͬͨΒnil • IntͱInt?·ͬͨ͘ҧ͏ܕ
ʢIntͱInt?ܭࢉͰ͖ͳ͍ʣ
ΦϓγϣφϧܕதΛऔΓग़͢ ʢڧ੍Ξϯϥοϓʣ 45 • ʂͰதΛऔΓग़͢ த͕nilͷ߹ʹ࣮ߦ࣌ΤϥʔʹͳΔ ʢ࣮ߦ࣌ΤϥʔΞϓϦ͕མͪΔݪҼʂ࣮֬ʹnil ͡Όͳ͍ͬͯΘ͔ͬͯΔͱ͖ʹ͏ʣ
ΦϓγϣφϧܕதΛऔΓग़͢ (νΣοΫͯ͠औΓग़͢) 46 • if let ͱ͍͏ߏจΛ͏ͱத͕͋ͬͨͱ͖͚ͩॲ ཧΛ͢Δ͜ͱ͕Ͱ͖Δ
࠶ೖͰ͖ͳ͍มlet 47 • ҰॳظԽ͢ΔͱΛมߋͰ͖ͳ͍ม • ΉΈʹมߋ͞ΕΔՄೳੑ͕͋ΔvarΛ͏ͷό άͷݩɻʢ׳Εͳ͍͏ͪجຊletΛ͍ɺมߋ͢ Δඞཁੑ͕ग़͖ͯͨΒvarʹมߋ͢Δͷ͕٢ɻʣ
ifจ 48 • ैདྷͷifจͱ΄΅มΘΒͣ • ݅ఆͷ෦ͷ()Λॻ͔ͳ͍ͷ͕ࠓ෩ʁ
switchจ 49 • ॻ͖ํैདྷͱ͋·ΓมΘΒ͕ͣͩ݅ͳͲΛࢦ ఆͰ͖ΔΑ͏ʹͳͬͯେ෯ύϫʔΞοϓʂ
forจ 50 • …͘͠..<ͰൣғࢦఆՄೳ • ैདྷͷforจʢԼʣSwift3.0Ͱͳ͘ͳΔ༧ఆ
forจ 51 • άϥϑͰͷมԽΛݟΕͨΓ͢Δ
ϝιου 52 • ࣗͰॲཧͷմΛఆٛͰ͖Δɻʢৄࡉޙͷत ۀͰʣ
ຊͷ͓͞Β͍ • ϓϩάϥϜͷֶशେͷSwiftͰܾ·Γʂ • PlaygroundͰͨ͘͞Μॻ͍֮ͯ͑Α͏ʂ • SwiftܕΛҙࣝ͢Δͷ͕ϙΠϯτʂ 53
ࢀߟਤॻ ৄղ Swift վగ൛ Xcode7.1Ͱಈ࡞֬ೝΛ͍ͯ͠Δͱͷ͜ͱ ͔ͬ͠Γղઆ͞Ε͍ͯΔͷͰͪΐͬͱ͠ Ί͔ɻΏͬ͘ΓਐΊ͍͖ͯ·͠ΐ͏ɻ ʢͰSwift3.0͕ग़Δલ·Ͱʹؤுͬͯʣ 54
ࠂ 55 http://love-swift.connpass.com/event/25716/ ݄࣍̏̎̕ʂ
ࠂ 56 http://liginc.co.jp/?p=228155 LIGϒϩά࿈ࡌ࢝Ί·ͨ͠ʂ