Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Swift 2.2 の新機能
Kazuki Ohara
April 02, 2016
Programming
0
310
Swift 2.2 の新機能
Kazuki Ohara
April 02, 2016
Tweet
Share
Other Decks in Programming
See All in Programming
Improve Build Times in Less Time
zacsweers
6
2.8k
The future of trust stores in Python
sethmlarson
0
180
microCMS × Shopifyで、ECサイトがリニューアル後急成長した話
microcms
0
460
Enterprise Angular: Frontend Moduliths with Nx and Standalone Components @jax2022
manfredsteyer
PRO
0
290
WindowsコンテナDojo:第2回 Windowsコンテナアプリのビルド、公開、デプロイ
oniak3ibm
PRO
0
140
Git Rebase
bkuhlmann
7
1k
Is Rust a great language for building Kubernetes ecosystem
deepu105
0
140
ebpfとWASMに思いを馳せる2022 / techfeed-conference-2022-ebpf-wasm-amsy810
masayaaoyama
0
570
Managing gRPC with Wire
oldergod
2
150
Kotlin 最新動向2022 #tfcon #techfeed
ntaro
1
970
Let's make a contract: the art of designing a Java API
mariofusco
0
160
Update from the Elixir team - 2022
whatyouhide
0
110
Featured
See All Featured
5 minutes of I Can Smell Your CMS
philhawksworth
196
18k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
103
16k
Navigating Team Friction
lara
175
11k
Building a Scalable Design System with Sketch
lauravandoore
447
30k
Designing for Performance
lara
596
63k
Code Reviewing Like a Champion
maltzj
506
37k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
3
430
Writing Fast Ruby
sferik
612
57k
Unsuck your backbone
ammeep
659
55k
Adopting Sorbet at Scale
ufuk
63
7.5k
Intergalactic Javascript Robots from Outer Space
tanoku
261
25k
Gamification - CAS2011
davidbonilla
75
3.9k
Transcript
4XJGUͷ৽ػೳ େݪҰً
ࣗݾհ w ඇܞଳ ήʔϜձࣾͰ ඇήʔϜ J04ΞϓϦΛ࡞ͬͯΔ ΤϯδχΞ w 4XJGUྐྵϲ݄ऑ w
5XJUUFS!PSDIFMZ w 'BDFCPPLLB[VLJPIBSB w 2JJUBPSDIFMZ
None
΄ͱΜͲͷ ΩʔϫʔυΛҾϥϕϧͰ ͑ΔΑ͏ʹ͢Δ
Ҿϥϕϧ indexOf(value, in: collection) ҾͷׂΛ໌֬ʹ͠ ՄಡੑΛ্ͤ͞Δ
Ͱ JOΩʔϫʔυ
let names = [ "C", "Objective-C", "Swift" ] for name
in names { print("Hello \(name)!") }
͑ͳ͍ʂ
4XJGUͰશͯͷΩʔϫʔυ͕ Ҿϥϕϧͱͯ͠ ͑ΔΑ͏ʹͳΓ·ͨ͠ ͨͩ͠MFU WBS JOPVUআ͘
λϓϧൺֱԋࢉࢠ
λϓϧΛ͑Ϋϥεɺ ߏମΛఆٛ͢Δ͜ͱͳ͘ ෳͷཁૉΛ࣋ͭσʔλΛѻ͑Δ let rhythm = (3, 3, 7)
͔ؔΒෳͷΛ ฦ͢߹ʹศར func getRhythm() -> (Int, Int, Int) { return
(3, 3, 7) } let rhythm = getRhythm()
͔͠͠ ൺֱԋࢉࢠ͕ͳ͍
let rhythm = getRhythm() if rhythm == (5, 7, 5)
{ print("haiku") } ͜ͷΤϥʔʹͳΔ
4XJGUͰλϓϧʹ͕ ͑ΔΑ͏ʹͳͬͨ ଞʹ
Ҿϥϕϧ͖ͷ ؔͷ໊લ
extension UIView { func insertSubview(view: UIView, at index: Int) func
insertSubview(view: UIView, aboveSubview siblingSubview: UIView) func insertSubview(view: UIView, belowSubview siblingSubview: UIView) } 4XJGUͰ໊લಉ͡ͰҾ ϥϕϧ͕ҧ͏͕ؔΑ͋͘Δ
͔͠͠ ݺͼग़͢Ҏ֎ͷతͰ ͜ͷؔΛࢦఆ͢Δ߹ɺ ҾϥϕϧΛ༩͑ΒΕͳ͍ͷͰ ᐆດʹͳΔ let someView: UIView = ...
let fn = someView.insertSubview
Ͳͷ JOTFSU4VC7JFX
4XJGUͰҾϥϕϧΛ ࢦఆͰ͖ΔΑ͏ʹͳͬͨ MFUGOTPNF7JFXJOTFSU4VCWJFX @BU MFUGOTPNF7JFXJOTFSU4VCWJFX @BCPWF4VCWJFX
ηϨΫλͷࢦఆํ๏
class NSNotificationCenter { func addObserver(_ observer: AnyObject, selector aSelector: Selector,
name aName: String?, object anObject: AnyObject?) } 4XJGUͰϝιουΛࢦఆ͢Δ ͨΊͷηϨΫλͱ͍͏ͷΛ ͏͜ͱ͕͋Δ
ྫϘϦϡʔϜ͕มԽͨ͠Β TFMG ଟ"QQ%FMFHBUF ͷ WPMVNF$IBOHFEϝιου͕ ݺΕΔΑ͏ʹొ͢Δ NotificationCenter.defaultCenter().addObserver(self, selector: "volumeChanged:", name:
"AVSystemController_SystemVolumeDidChangeNotification", object: nil) ηϨΫλʹจࣈྻΛͬͯ ϝιουΛࢦఆ͍ͯ͠Δ
ίϯύΠϥจࣈྻͷ༰Λ νΣοΫ͠ͳ͍ ଘࡏ͠ͳ͍ϝιουͩͱ ࣮ߦ࣌Τϥʔ͕ى͖Δʂ
͜Μͳͷόάͷݩ Ͱ͢ΑͶ
4XJGUͰ͜͏ॻ͚·͢ ଘࡏ͠ͳ͍ϝιουΛࢦఆ͢Δͱ ίϯύΠϧΤϥʔʹͳΓ ࣮ߦ࣌ΤϥʔΛ͛·͢ NotificationCenter.defaultCenter().addObserver(self, selector: #selector(AppDelegate.volumeChanged(_:)), name: "AVSystemController_SystemVolumeDidChangeNotification", object:
nil)
͋Γ͕ͱ͏ ͍͟͝·ͨ͠