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アプリ開発入門_07
Search
jollyjoester
March 26, 2016
Education
0
110
Swiftで作るiOSアプリ開発入門_07
Schoo講義資料
jollyjoester
March 26, 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
東工大 traP Kaggle班 機械学習講習会 2024
abap34
2
310
アニメに学ぶチームの多様性とコンピテンシー
terahide
0
240
Adobe Express
matleenalaakso
1
7.5k
Chapitre_1_-__L_atmosphère_et_la_vie_-_Partie_2.pdf
bernhardsvt
0
200
"数学" をプログラミングしてもらう際に気をつけていること / Key Considerations When Programming "Mathematics"
guvalif
0
560
H5P-työkalut
matleenalaakso
4
36k
ACT FAST 20240830
japanstrokeassociation
0
320
小学生にスクラムを試してみた件~中学受検までの100週間の舞台裏~
ukky86
0
340
Library Prefects 2024-2025
cbtlibrary
0
110
Repaso electricidade e electrónica
irocho
0
200
1113
cbtlibrary
0
260
Master of Applied Science & Engineering: Computer Science & Master of Science in Applied Informatics
signer
PRO
0
430
Featured
See All Featured
Teambox: Starting and Learning
jrom
133
8.8k
Six Lessons from altMBA
skipperchong
27
3.5k
Become a Pro
speakerdeck
PRO
25
5k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
We Have a Design System, Now What?
morganepeng
50
7.2k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Transcript
SwiftͰ࡞Δ iOSΞϓϦ։ൃೖ 7ݶɿΞϓϦͰԻΛ໐Βͯ͠ΈΔ 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/06.zip
7
ຊͷϝχϡʔ • ԻͷૉࡐΛऔಘ͢Δ • ޮՌԻΛ໐Βͯ͠ΈΔ • BGMΛ໐Βͯ͠ΈΔ 8
ͦͷલʹલճͷ࣭͝ ʢΞϓϦͷݟͨΛߏ͢ΔViewͷཧղʣ • ʮ animalLabel.text = ʯͷͷֆจࣈɺγϡϛϨʔλͰ ඳࣸ͞Ε͍ͯ·͕ͨ͠ɺ͜ͷֆจࣈͷਖ਼ମͳΜͰ͔͢ʁ ΞϓϦ։ൃͰී௨ʹ͑ΔΜͰ͢Ͷɻ from
อࢤ ݈Ұ͞Μ ‣ ֆจࣈจࣈͰ͢ɻΞϓϦ։ൃͰී௨ʹ͑·͢ɻྫ͑ U+1F42Fͱ͍͏ׂ͕ΓͯΒΕ͍ͯ·͢ɻ͜ ͷͩͬͨΒͱ͍͏ֆจࣈͩͱఆͰ͖ΔڥͳΒ ͪΌΜͱֆจࣈ͕දࣔ͞Ε·͢ɻʢৄ͘͠จࣈίʔ υͱ͔ษڧͯ͠Έ͍ͯͩ͘͞ʣ 9
Έͳ͞·࣭͋Γ·ͨ͠Βͥͻ࣭͍ͩ͘͝͞ɻ तۀதʹऔΓ্͛ΒΕͳͯ͘ ग़དྷΔݶΓ͓͑͠·͢ʂ ͳΔ΄ͲʂͱࢥͬͨΒʮͳΔ΄ͲʯϘλϯΛ ԡ͍͚ͯͨͩ͠ΔͱྭΈʹͳΓ·͢(`ŋωŋ´) 10
ԻͷૉࡐΛऔಘ͢Δ 11
iOSͰ࠶ੜͰ͖ΔϑΥʔϚοτ 12 https://developer.apple.com/library/ios/documentation/ AudioVideo/Conceptual/MultimediaPG/UsingAudio/ UsingAudio.html ϑΥʔϚοτ ֦ுࢠ AIFF .aif, .aiff
CAF .caf MP3 .mp3 MPEG2 .aac MPEG4 .m4a, .mp4 WAV .wav
ԻϑΝΠϧΛ࡞Δ 13 GarageBand Ͱ͖ͨΒ͍͍ͳɾɾɾ
ԻϑΝΠϧΛ୳͢ 14 ԻૉࡐαΠτͳͲ͔Β୳͢
ԻϑΝΠϧΛ୳͢ 15 • ར༻نʹҙ ‣ ༻ར༻͕ڐՄ͞Ε͍ͯΔ͔ʁ ‣ ࡞ऀͷΫϨδοτ͕ඞཁ͔Ͳ͏͔ʁ ‣ ݩͷ࡞ʹվม͕ڐՄ͞Ε͍ͯΔ͔ʁ
‣ վม࣌ͷϥΠηϯεͲ͏ͳΔ͔ʁ
ԻϑΝΠϧΛ୳͢ 16 • ޮՌԻϥϘʢಈͷ໐͖ʣ ‣ http://soundeffect-lab.info/sound/animal/ • ຐԦࠢʢBGMʣ ‣ http://maoudamashii.jokersounds.com/
list/game13.html ʢΠϕϯτ43ͷۂʣ
ԻϑΝΠϧΛXcodeʹimport 17 ͜͜Ͱsoundͱ͍͏groupʢϑΥϧμΈ͍ͨͳͷʣ Λ࡞ͯ͠ԻϑΝΠϧΛ·ͱΊ͍ͯ·͢
ޮՌԻΛ໐Βͯ͠ΈΔ 18
ޮՌԻΛ໐Βͯ͠ΈΔ • AnimalFortuneTellingϓϩδΣΫτΛ։͘ https://github.com/jollyjoester/Schoo-iOS- App-Development-Basic/archive/06.zip • ViewController.swiftΛબ 19
ͦͷલʹͪΐͬͱมߋ 20 ViewController.swift changeLabelϝιου
͍݁Ռ͕ग़ͨΒϫϯͱ໐Β͢ 21 • AVAudioPlayerΛར༻ ‣ AVFoundation.frameworkʹؚ·ΕΔ ‣ ؆୯ʹԻΛѻ͏͜ͱ͕Ͱ͖Δ
͍݁Ռ͕ग़ͨΒϫϯͱ໐Β͢ 22 ViewController.swift AVAudioPlayer༻ͷมΛՃ
͍݁Ռ͕ग़ͨΒϫϯͱ໐Β͢ 23 ViewController.swift changeLabelϝιου switchจͷԼʹԼهՃ
͍݁Ռ͕ग़ͨΒϫϯͱ໐Β͢ 24
͍݁Ռ͕ग़ͨΒϫϯͱ໐Β͢ (do-try-catch) 25 AVAudioPlayer(contentsOfURL: url)ࣦഊ͢ΔՄೳੑͷ͋Δॲཧ ࣦഊͨ͠ΒΤϥʔΛΩϟονͯ͠Τϥʔ༻ͷॲཧΛ͢Δ
͍݁Ռ͕ग़ͨΒϫϯͱ໐Β͢ (do-try-catch) 26 ྫɿtypoʢλΠϓϛεʣͰ֘ͷԻϑΝΠϧ͕ଘࡏ͠ͳ͔ͬͨ߹
͍݁Ռ͕ग़ͨΒϫϯͱ໐Β͢ (do-try-catch) 27 do-catchͰғΘͳ͔ͬͨΒʁ ʮ͔͜͜ΒΤϥʔ͕εϩʔ͞Εͯϋϯυϧ͞Εͯ·ͤΜɻʯ
͍݁Ռ͕ग़ͨΒϫϯͱ໐Β͢ (༨ஊ: Bundleͱʁ) 28
͍݁Ռ͕ग़ͨΒϫϯͱ໐Β͢ (༨ஊ: Bundleͱʁ) 29 Xcodeʹimportͨ͠ૉࡐʢը૾Իʣ ΞϓϦͷBundleͱ͍͏ྖҬʹίϐʔ͞Ε·͢
ͦΕͧΕͷಈͰ໐͔ͤͯΈΔ 30 soundNameͱ͍͏มΛએݴ͢Δ
ͦΕͧΕͷಈͰ໐͔ͤͯΈΔ 31 ֤ಈͷ໐͖ͷԻϑΝΠϧ໊Λࢦఆ͢Δ
ͦΕͧΕͷಈͰ໐͔ͤͯΈΔ 32
BGMΛ໐Βͯ͠ΈΔ 33
ΫϨδοτΛදࣔ 34 ຐԦࠢΫϨδοτͷද͕ࣔඞཁ
BGMΛ໐Βͯ͠ΈΔ 35 BGM༻ͷAVAudioPlayerΛ࡞ ViewDidLoadϝιουͷதͰԻΛ࠶ੜ͢Δ
ViewDidLoad 36 ը໘͕४උ͞Εͨ࣌ʹ̍ճ͚࣮ͩߦ͞ΕΔϝιου ʢৄ࣍͘͠ճʹʣ
BGMΛ໐Βͯ͠ΈΔ 37 ԻΛଈ࣌ʹ໐Β͢ઃఆ
BGMΛ໐Βͯ͠ΈΔ 38 ϧʔϓͤ͞Δઃఆ
BGMΛ໐Βͯ͠ΈΔ 39 ԻྔΛௐ
40 ʂ
BGMΛ໐Βͯ͠ΈΔ 41 Ϩʔτʢૣ͞ʣΛௐ
BGMΛ໐Βͯ͠ΈΔ 42 ԻΛ్த͔Β࠶ੜ͢Δ
BGMΛ໐Βͯ͠ΈΔ 43 ύχϯάʢࠨӈͷεϐʔΧʔͷԻௐʣ
BGMΛ໐Βͯ͠ΈΔ 44 Ұ࣌ఀࢭˍ࠶։ changeLabelͷ࠷ޙʹՃͯ͠ΈΑ͏
BGMΛ໐Βͯ͠ΈΔ 45 ఀࢭ
γϛϡϨʔλʔͱ࣮ػ 46 • γϛϡϨʔλʔͱ࣮ػͷಈ͖ͷҧ͍ʹ ҙʂ ‣ γϛϡϨʔλʔͩͱϗʔϜϘλϯΛԡ͠ ͯΞϓϦΛऴྃͤͯ͞Ի͕ͳΓଓ͚ Δ ‣
ϋʔυΣΞ͕ؔΘΔͷ࣮ػͰͷಈ ࡞֬ೝΛ͔ͬ͠Γʂ
ෳͷޮՌԻΛಉ࣌ʹ໐Β͢ 47 • Իͷछྨ͝ͱʹAVAudioPlayerͷม͕ඞ ཁʢࠓճͩͱplayerͱbgmPlayerʣ • ͨ͘͞ΜͷԻΛಉ࣌ʹѻ͍͍ͨͱ͖ ͪΐͬͱ͕ඞཁʢੈքҰຊʹࡌͬͯ ΔΑŬź(ɾ㱼ɾ)Ŭźʣ
ຊͷ͓͞Β͍ • ྑ͍ԻૉࡐΛऔಘͯ͠ΑΓྑ͍ΞϓϦʹ͠Α͏ʂ • AVAudioPlayerͷ͍ํΛϚελʔͯ͢͠Δͱ ΞϓϦΑΓָ͘͠ͳΔʂ 48
ࠂ 49 http://eventdots.jp/event/582698 ݄࣍̏̎̕ʂ
ࠂ 50 http://liginc.co.jp/series/spaceapps LIGϒϩά࿈ࡌ࢝Ί·ͨ͠ʂ