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アプリ開発入門_08
Search
jollyjoester
April 02, 2016
Education
0
92
Swiftで作るiOSアプリ開発入門_08
Schoo講義資料
jollyjoester
April 02, 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
【COPILOT無料セミナー】エンゲージメントと自律性の高いプロジェクト型人材育成に向けて~プロジェクト・ベースド・ラーニング(PBL)という選択肢~
copilot
PRO
0
130
H5P-työkalut
matleenalaakso
4
36k
JavaScript - Lecture 6 - Web Technologies (1019888BNR)
signer
PRO
0
2.5k
小・中・高等学校における情報教育の体系的な学習を目指したカリキュラムモデル案/curriculum model
codeforeveryone
2
2.3k
20240810_ワンオペ社内勉強会のノウハウ
ponponmikankan
2
880
Comment aborder et contribuer sereinement à un projet open source ? (Masterclass Université Toulouse III)
pylapp
0
3.2k
1030
cbtlibrary
0
300
Design Guidelines and Models - Lecture 5 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
680
SQL初級中級_トレーニング【株式会社ニジボックス】
nbkouhou
0
19k
Library Prefects 2024-2025
cbtlibrary
0
110
Web 2.0 Patterns and Technologies - Lecture 8 - Web Technologies (1019888BNR)
signer
PRO
0
2.4k
世界のオープンソースロボットたち #1
shiba_8ro
0
140
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
How GitHub (no longer) Works
holman
310
140k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
96
Build your cross-platform service in a week with App Engine
jlugia
229
18k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Adopting Sorbet at Scale
ufuk
73
9.1k
What's in a price? How to price your products and services
michaelherold
243
12k
Transcript
SwiftͰ࡞Δ iOSΞϓϦ։ൃೖ 8ݶɿΞϓϦͷϥΠϑαΠΫϧΛཧղ͢Δ 1
ࣗݾհ ࣣౡҒ೭ʢͳͳ͠·ͻͰΏ͖ʣ Reproגࣜձࣾ iPhoneΞϓϦ։ൃ͕͖ 2
ࣗݾհ 3 https://repro.io
ຊίʔεͷඪ ۤΛΓӽ͑ͯ ָ͘͠ΞϓϦ։ൃͰ͖ΔΑ͏ʹͳΔʂ 4
෭ڭࡐ վగ൛ No.1εΫʔϧߨࢣਞʹΑΔ ੈքҰड͚͍ͨ iPhoneΞϓϦ։ൃͷतۀ (ٕज़ධࣾ) 5 AmazonͰˑ5ϨϏϡʔ͕૿͑ͯͨ⽃
ࠓճͷतۀͷඪ ΞϓϦͷϥΠϑαΠΫϧΛཧղ͢Δ 6
तۀͷલఏ݅ • ͓खݩͷMacʹXcode(version7.0Ҏ্)͕Πϯετʔ ϧ͞Ε͍ͯΔ͜ͱ • લճͷ͍ΞϓϦϓϩδΣΫτ͕͋ΔͱΑΓ༗ޮʹ ֶशͰ͖·͢ɻϓϩδΣΫτԼه͔Βμϯϩʔ υͰ͖·͢ɻ https://github.com/jollyjoester/Schoo-iOS-App- Development-Basic/archive/07.zip
7
ຊͷϝχϡʔ • ʢ४උʣը໘ભҠΛͯ͠ΈΔ • ը໘ͷϥΠϑαΠΫϧΛΔ • ΞϓϦͷϥΠϑαΠΫϧΛΔ 8
ͦͷલʹલճͷ࣭͝ ʢΞϓϦͰԻΛ໐Βͯ͠ΈΔʣ • ྫ֎ॲཧͬͯͳΜͰ͍ΔΜͰ͔͢ʁϋʔυΣΞΛ͏Α ͏ͳϓϩάϥϜྫ֎ॲཧ͕ඞཁͳ͜ͱ͓͓͍ΜͰ͢ ͔ ʁfrom தࢁ ཅհ͞Μ ‣
ྫ֎ΤϥʔॲཧΛ༰қʹ͢ΔͨΊʹ͋Γ·͢ɻͲ͜Ͱ Τϥʔ͕ൃੜ͢Δ͔͕Θ͔Γ͘͢ͳΓ·͢ʢdo-tryͷ தͰൃੜ͢Δʣ͠ɺΤϥʔ͕ൃੜͨ͠ͱ͖ʹ͠ͳ͚Ε ͳΒͳ͍͜ͱ͖ͬΓͱ͠·͢ʢcatchͷதʣɻ࠷ ۙͷݴޠͰ͋Ε͍͍ͩͨྫ֎ͱ͍͏ΈΛඋ͑ͯ ͍·͢ɻ 9
ͦͷલʹલճͷ࣭͝ ʢΞϓϦͰԻΛ໐Βͯ͠ΈΔʣ • ࠓͷतۀ༰ͷԠ༻ͰϏʔτϚχΞͷΑ͏ͳΞϓϦ࡞ Εͯ͠·͍·͔͢ʁ࣌ྲྀߦͬͯϋϚΓ·ͨ͠ͷͰɺ໘ന ͦ͏ͱࢥ͍·ͨ͠ɻfrom อࢤ ݈Ұ͞Μ ‣ ͪΖΜ࡞Ε·͢ʂ࣍ճͷδΣενϟʔΛݕ͢ΔΛ
ֶλοϓεϫΠϓΛͬͨΞϓϦΛ࡞ΕΔΑ͏ ʹͳΓ·͢ɻBGMΛྲྀͭͭ͠ɺλοϓεϫΠϓ͕λ Πϛϯάྑ͘͞Ε͔ͨΛఆͯ͠ɺGreatʂͱ͔Λදࣔ ͢ΔΑ͏ʹ͢ΕΠέͦ͏Ͱ͢Ͷɻ 10
Έͳ͞·࣭͋Γ·ͨ͠Βͥͻ࣭͍ͩ͘͝͞ɻ तۀதʹऔΓ্͛ΒΕͳͯ͘ ग़དྷΔݶΓ͓͑͠·͢ʂ ͳΔ΄ͲʂͱࢥͬͨΒʮͳΔ΄ͲʯϘλϯΛ ԡ͍͚ͯͨͩ͠ΔͱྭΈʹͳΓ·͢(`ŋωŋ´) 11
ʢ४උʣը໘ભҠΛͯ͠ΈΔ 12
13 ·࣮ͣફ
৽͍͠ը໘Λ࡞Δ • खॱ ‣ StoryboardʹViewControllerΛՃ͢Δ ‣ ιʔεϑΝΠϧʢxxxViewController.swiftʣΛՃ͢Δ ‣ StoryboardͷViewControllerͱιʔεΛඥ͚Δ 14
৽͍͠ը໘Λ࡞Δ ʢStoryboardͰը໘(ViewController)ΛՃ͢Δʣ 15
৽͍͠ը໘Λ࡞Δ ʢViewControllerͷαΠζΛมߋ͢Δʣ 16
৽͍͠ը໘Λ࡞Δ (ରԠ͢ΔιʔεϑΝΠϧΛ࡞͢Δ) 17
৽͍͠ը໘Λ࡞Δ (ରԠ͢ΔιʔεϑΝΠϧΛ࡞͢Δ) 18
৽͍͠ը໘Λ࡞Δ (ରԠ͢ΔιʔεϑΝΠϧΛ࡞͢Δ) 19
৽͍͠ը໘Λ࡞Δ (ରԠ͢ΔιʔεϑΝΠϧΛ࡞͢Δ) 20 ߲ આ໌ ೖྗ Class: ͜Ε͔Β࡞ΔViewControllerͷ໊લ SecondViewController Subclass
of: ͲΜͳػೳΛҾ͖ܧ͙͔ UIViewController Also create XIB file ݸผը໘ͷݟͨΛ࡞ΔXIBͱ͍͏ ͷΛ࡞Δ νΣοΫ͠ͳ͍ Language: ༻͢Δϓϩάϥϛϯάݴޠ Swift
৽͍͠ը໘Λ࡞Δ (ରԠ͢ΔιʔεϑΝΠϧΛ࡞͢Δ) 21
৽͍͠ը໘Λ࡞Δ (ରԠ͢ΔιʔεϑΝΠϧΛ࡞͢Δ) 22
৽͍͠ը໘Λ࡞Δ (࡞ͨ͠ιʔεͱStoryboardͷViewControllerΛඥ͚ͮΔ) 23
ը໘ભҠΛ͢Δ • खॱ ‣ ը໘ભҠͷΞΫγϣϯʢϘλϯͳͲʣΛՃ͢Δ ‣ ΞΫγϣϯ͔ΒભҠઌͷը໘ʹSegueΛଓ͢Δ 24
ը໘ભҠΛ͢Δ ʢը໘ભҠ͢ΔϘλϯΛՃ͢Δʣ 25
ը໘ભҠΛ͢Δ ʢը໘ભҠ͢ΔϘλϯΛՃ͢Δʣ 26
ը໘ભҠΛ͢Δ ʢϘλϯ͔Β࣍ը໘SegueΛଓ͢Δʣ 27
ը໘ભҠΛ͢Δ ʢϘλϯ͔Β࣍ը໘SegueΛଓ͢Δʣ 28
ը໘ભҠΛ͢Δ ʢϘλϯ͔Β࣍ը໘SegueΛଓ͢Δʣ 29
ը໘ભҠΛ͢Δ ʢ༨ஊɿ࠷ॳͷը໘Λࢦఆ͢Δʣ 30
ը໘ભҠΛ͢Δ ʢΕͳ͍ʣ 31 ❌
ը໘ભҠΛ͢Δ ʢφϏήʔλʔίϯτϩʔϥʔͰΕΔΑ͏ʹ͢Δʣ 32
ը໘ભҠΛ͢Δ ʢφϏήʔλʔίϯτϩʔϥʔͰΕΔΑ͏ʹ͢Δʣ 33
ը໘ભҠΛ͢Δ ʢΕͨʂ͚Ͳͪΐͬͱҧ͏ʣ 34
ը໘ભҠΛ͢Δ ʢ࠷ॳͷը໘ͷφϏήʔλʔίϯτϩʔϥʔΛඇදࣔʹ͢Δʣ 35 ViewController.swift
ը໘ભҠΛ͢Δ ʢભҠઌͷը໘ͷφϏήʔλʔίϯτϩʔϥʔΛදࣔ͢Δʣ 36 SecondViewController.swift
ը໘ભҠΛ͢Δ ʢͰ͖ͨʂʣ 37
ը໘ભҠΛ͢Δ ʢ͓·͚ʣ 38
39 ը໘ͷϥΠϑαΠΫϧΛΔ
40 ͔͜͜Β࠲ֶ
UIViewController 41 ͜Ε·Ͱ࣮͖ͯͨ͠ϓϩάϥϜશ෦ ViewController.swiftʹॻ͍͖ͯ·ͨ͠ ↓ ViewControllerͱԿͰ͠ΐ͏ʁ
UIViewController 42 ViewControllerͱʁ ↓ ը໘Λίϯτϩʔϧ͢Δͷ
UIViewController ʢܧঝʣ 43 ʰܧঝʱͱ͍͏ΈͰ͢Ͱʹ͋Δ UIViewControllerͷػೳΛҾ͖ܧ͍Ͱ ʮViewControllerʯͱ͍͏ը໘Λ࡞͍ͬͯΔ
UIViewController ʢoverrideʣ 44 ը໘ʹඞཁͳػೳͷ΄ͱΜͲ͕ UIViewControllerʹඋΘ͍ͬͯΔ͕ɺΞϓϦݻ ༗ͷॲཧΛՃ͍͑ͨͱ͖ʹʰoverrideʱʢ্ ॻ͖ʣͱ͍͏ΈͰಠࣗॲཧΛՃ͢Δ
UIViewController ʢ͍ͭݺΕΔʁʣ 45 viewDidLoadͱ͍͏ϝιου ࣗͰݺΜͰ͍ͳ͍͚Ͳ࣮ߦ͞ΕΔ ↓ UIViewControllerͷΈͰಛఆͷλΠϛϯάͰ ࣗಈతʹݺΕ͍ͯΔ
UIViewController ʢsuper.viewDidLoad()ʣ 46 ୯७ʹ্ॻ͖ͪ͠Ό͏ͱݩͷॲཧ͕ͳ͘ͳͬ ͯ͠·͏ͷͰsuperͰݩͷॲཧΛݺΜ্ͩͰͦ ͷԼʹಠࣗॲཧΛॻ͘
UIViewController ʢ্ॻ͖Ͱ͖Δॲཧ͍͔ͭ͋͘Δʣ 47 ϝιου໊ ݺΕΔλΠϛϯά viewDidLoad ը໘͕࡞ΒΕͨͱ͖ viewWillAppear ը໘͕දࣔ͞ΕΔલ viewDidApear
ը໘͕දࣔ͞Εͨޙ viewWillDisappear ը໘͕ফ͑Δલ viewDidDisappear ը໘͕ফ͑ͨޙ
࣮ࡍʹ֬ೝͯ͠ΈΑ͏ʂ 48 ViewController.swift
࣮ࡍʹ֬ೝͯ͠ΈΑ͏ʂ 49 SecondViewController.swift
࣮ࡍʹ֬ೝͯ͠ΈΑ͏ʂ 50
ϥΠϑαΠΫϧΛͬͨ۩ମྫ ʢ͏Ұͭͷը໘ͰԻΛ໐Β͞ͳ͍ʣ 51
UIViewController ʢUIViewControllerΛৄ͘͠ΈΔʣ 52
UIViewController ʢUIViewControllerΛৄ͘͠ΈΔʣ 53
54 ΞϓϦͷϥΠϑαΠΫϧΛΔ
ΞϓϦͷϥΠϑαΠΫϧ 55 • ΞϓϦͷىಈɺऴྃͳͲͷλΠϛϯάͰ ࣗಈతʹݺΕΔॲཧ͕͋Δ • AppDelegate.swift
AppDelegate 56 ϝιου໊ ݺΕΔλΠϛϯά application:didFinishLaunching WithOptions ΞϓϦ͕ϝϞϦ্ʹͳ͍ঢ়ଶͰ ىಈͨ͠ͱ͖ applicationWillResignActive ΞϓϦ͕ΞΫςΟϒͰͳ͘ͳΔͱ͖
applicationDidEnterBackground ΞϓϦ͕όοΫάϥϯυ ߦͬͨͱ͖ applicationWillEnterForeground ΞϓϦ͕ϑΥΞάϥϯυʹߦ͘ͱ͖ applicationDidBecomeActive ΞϓϦ͕ΞΫςΟϒʹͳͬͨͱ͖ applicationWillTerminate ΞϓϦ͕ऴྃͨ͠ͱ͖
࣮ࡍʹ֬ೝͯ͠ΈΑ͏ʂ 57 AppDelegate.swift
࣮ࡍʹ֬ೝͯ͠ΈΑ͏ʂ 58 • ΞϓϦىಈ • ௨ηϯλʔ or ίϯτϩʔϧηϯλʔ։ ͘ด͡Δ •
ϗʔϜϘλϯͰΞϓϦΛऴྃ͢Δ
࣮ࡍʹ֬ೝͯ͠ΈΑ͏ʂ 59 • ࠶ΞϓϦΛ্ཱͪ͛Δ • ϗʔϜϘλϯͰΞϓϦΛऴྃ͢Δ • ϝϞϦ͔Βআͯ͠શʹऴ͔ྃͤͯ͞ Β࠶ΞϓϦΛ্ཱͪ͛Δ
ຊͷ͓͞Β͍ • ը໘ɺΞϓϦͷϥΠϑαΠΫϧΛ্ͬͨͰదͳ λΠϛϯάʹॲཧΛ࣮͠Α͏ʂ 60
ࠂ 61 http://love-swift.connpass.com/ ࣍4݄24ʂ
ࠂ 62 http://liginc.co.jp/series/spaceapps LIGϒϩά࿈ࡌ࢝Ί·ͨ͠ʂ