Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift 2.2 の新機能

Swift 2.2 の新機能

420098acfbafc9588201d19fbc515e13?s=128

Kazuki Ohara

April 02, 2016
Tweet

Other Decks in Programming

Transcript

  1. 4XJGUͷ৽ػೳ େݪҰً

  2. ࣗݾ঺հ w ඇܞଳ ήʔϜձࣾͰ ඇήʔϜ J04ΞϓϦΛ࡞ͬͯΔ ΤϯδχΞ w 4XJGUྐྵ͸ϲ݄ऑ w

    5XJUUFS!PSDIFMZ w 'BDFCPPLLB[VLJPIBSB w 2JJUBPSDIFMZ
  3. None
  4. ΄ͱΜͲͷ  ΩʔϫʔυΛҾ਺ϥϕϧͰ ࢖͑ΔΑ͏ʹ͢Δ

  5. Ҿ਺ϥϕϧ indexOf(value, in: collection) Ҿ਺ͷ໾ׂΛ໌֬ʹ͠ ՄಡੑΛ޲্ͤ͞Δ

  6. Ͱ΋ JO͸Ωʔϫʔυ

  7. let names = [ "C", "Objective-C", "Swift" ] for name

    in names { print("Hello \(name)!") }
  8. ࢖͑ͳ͍ʂ

  9. 4XJGUͰ͸શͯͷΩʔϫʔυ͕ Ҿ਺ϥϕϧͱͯ͠ ࢖͑ΔΑ͏ʹͳΓ·ͨ͠ ͨͩ͠MFU WBS JOPVU͸আ͘

  10. λϓϧൺֱԋࢉࢠ

  11. λϓϧΛ࢖͑͹Ϋϥεɺ ߏ଄ମΛఆٛ͢Δ͜ͱͳ͘ ෳ਺ͷཁૉΛ࣋ͭσʔλΛѻ͑Δ let rhythm = (3, 3, 7)

  12. ؔ਺͔Βෳ਺ͷ஋Λ ฦ͢৔߹౳ʹศར func getRhythm() -> (Int, Int, Int) { return

    (3, 3, 7) } let rhythm = getRhythm()
  13. ͔͠͠ ൺֱԋࢉࢠ͕ͳ͍

  14. let rhythm = getRhythm() if rhythm == (5, 7, 5)

    { print("haiku") } ͜ͷ͸ΤϥʔʹͳΔ
  15. 4XJGUͰλϓϧʹ͕ ࢖͑ΔΑ͏ʹͳͬͨ ଞʹ ౳΋

  16. Ҿ਺ϥϕϧ෇͖ͷ ؔ਺ͷ໊લ

  17. extension UIView { func insertSubview(view: UIView, at index: Int) func

    insertSubview(view: UIView, aboveSubview siblingSubview: UIView) func insertSubview(view: UIView, belowSubview siblingSubview: UIView) } 4XJGUͰ͸໊લ͸ಉ͡ͰҾ਺ ϥϕϧ͕ҧ͏ؔ਺͕Α͋͘Δ
  18. ͔͠͠ ݺͼग़͢Ҏ֎ͷ໨తͰ ͜ͷؔ਺Λࢦఆ͢Δ৔߹ɺ Ҿ਺ϥϕϧΛ༩͑ΒΕͳ͍ͷͰ ᐆດʹͳΔ let someView: UIView = ...

    let fn = someView.insertSubview
  19. Ͳͷ JOTFSU4VC7JFX

  20. 4XJGUͰ͸Ҿ਺ϥϕϧΛ ࢦఆͰ͖ΔΑ͏ʹͳͬͨ MFUGOTPNF7JFXJOTFSU4VCWJFX @BU 
 MFUGOTPNF7JFXJOTFSU4VCWJFX @BCPWF4VCWJFX

  21. ηϨΫλͷࢦఆํ๏

  22. class NSNotificationCenter { func addObserver(_ observer: AnyObject, selector aSelector: Selector,

    name aName: String?, object anObject: AnyObject?) } 4XJGUͰ͸ϝιουΛࢦఆ͢Δ ͨΊͷηϨΫλͱ͍͏΋ͷΛ ࢖͏͜ͱ͕͋Δ
  23. ྫϘϦϡʔϜ͕มԽͨ͠Β TFMG ଟ෼"QQ%FMFHBUF ͷ WPMVNF$IBOHFEϝιου͕ ݺ͹ΕΔΑ͏ʹొ࿥͢Δ NotificationCenter.defaultCenter().addObserver(self, selector: "volumeChanged:", name:

    "AVSystemController_SystemVolumeDidChangeNotification", object: nil) ηϨΫλʹจࣈྻΛ࢖ͬͯ ϝιουΛࢦఆ͍ͯ͠Δ
  24. ίϯύΠϥ͸จࣈྻͷ಺༰Λ νΣοΫ͠ͳ͍ ଘࡏ͠ͳ͍ϝιουͩͱ ࣮ߦ࣌Τϥʔ͕ى͖Δʂ

  25. ͜Μͳͷόάͷݩ Ͱ͢ΑͶ

  26. 4XJGUͰ͸͜͏ॻ͚·͢ ଘࡏ͠ͳ͍ϝιουΛࢦఆ͢Δͱ ίϯύΠϧΤϥʔʹͳΓ ࣮ߦ࣌ΤϥʔΛ๷͛·͢ NotificationCenter.defaultCenter().addObserver(self, selector: #selector(AppDelegate.volumeChanged(_:)), name: "AVSystemController_SystemVolumeDidChangeNotification", object:

    nil)
  27. ͋Γ͕ͱ͏ ͍͟͝·ͨ͠