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

Swiftへの愛2018

C0c3e2b792a468590679e46b86e1784d?s=47 hirothings
December 08, 2018

 Swiftへの愛2018

Swiftの魅力
最近のSwift
これからのSwift
について発表した資料になります

C0c3e2b792a468590679e46b86e1784d?s=128

hirothings

December 08, 2018
Tweet

More Decks by hirothings

Other Decks in Programming

Transcript

  1. Love Swift 2018 @hirothings

  2. 10෼Ͱ࿩͢͜ͱ • Swiftͱ͸ʁ • Swiftͷັྗ • ࠷ۙͷSwift • ͜Ε͔ΒͷSwift •

    Hello Swift!
  3. ࣗݾ঺հ • @hirothings (Objective-ͻΖC) • ݩϥʔϝϯ԰ళ௕ • ৭ʑ͋ͬͯݱࡏiOSσϕϩούʔ

  4. Swiftͱͷग़ձ͍ • ΤϯδχΞͱͯ͠ΩϟϦΞΛελʔτͨ͠2015೥ ౙ..ɻ • ͦΕ·ͰJS, PHPΛগʑ͚ͩͬͨͲઓྗʹͳΒͣɺ Ҋ݅ͷSwiftࢼͯ͠ΈΔ୲౰ʹͳΓSwiftͱग़ձ͏͜ ͱʹ

  5. Swiftͱ͸ • Apple͕2014೥ʹൃදͨ͠ϓϩάϥϛϯάݴޠ • ͷͪΦʔϓϯιʔεԽ https://github.com/apple/swift • ࣮ߦ଎౓͕଎͍, Ϟμϯ, ҆શ

    • ΞΠίϯ͸ΞϚπόϝ https://www.apple.com/jp/swift/ ΑΓ
  6. Swiftͷັྗ • ݫ֨ͳܕγεςϜ • Ϟμϯͳจ๏ • null҆શͳݴޠ • ஋ܕத৺ͷݴޠ •

    GenericsΛ༻͍ͨॊೈ͞
  7. ݫ֨ͳܕγεςϜ • ੩తܕ෇͚ݴޠ • ίϯύΠϥ͕ίʔυͷ҆શੑΛ୲อͯ͘͠ΕΔ • ҉໧తͳίʔυ͕গͳ͘ͳΔ • ܕʹରͯ͠ݫࣗ͘͠વͱλΠϓηʔϑͳॻ͖ํ Λ਎ʹ͚ͭΒΕΔ

  8. Ϟμϯͳจ๏ • ܕਪ࿦ • Ϋϩʔδϟ • ߴ֊ؔ਺ (map, flatMap, filter,

    reduce..) • ϓϩτίϧ / ϓϩτίϧ֦ு • δΣωϦΫε • λϓϧ / ෳ਺ͷ໭Γ஋ • ϝϞϦͷࣗಈ؅ཧ(ARC)
  9. null҆શͳݴޠ null҆શͱ͸: null͕ݪҼͰ࣮ߦ࣌ΤϥʔʹͳΒͳ͍࢓૊Έ OVMM҆શͰͳ͍ݴޠ͸ɺ΋͸΍ϨΨγʔݴޠͩIUUQTRJJUBDPNLPIFSJUFNT FCECBCΑΓ

  10. null҆શͳݴޠ • nullνΣοΫΛίϯύΠϧ࣌ʹνΣοΫͰ͖Δ • मਖ਼͠ͳ͍ͱͦ΋ͦ΋Ϗϧυ͕௨Βͳ͍

  11. ஋ܕத৺ͷݴޠ ࢀরܕͷ໰୊఺ • ίʔυΛ௥Θͳ͍ͱɺͲ͜·ͰΠϯελϯε͕ ڞ༗͞Ε͍ͯΔͷ͔ෆ໌ +BWBTDSJQUͷ"SSBZ ࢀরܕ ͷྫ

  12. ඪ४ϥΠϒϥϦͷ΄ͱΜͲ͕ ஋ܕ • String • Array • Dictionary • Bool

    • Int • Double • Float
  13. ίϐʔ͝ͱʹίετ͕͔͔Δ ͷͰ͸ʁ

  14. Copy on Write • ୅ೖ࣌఺Ͱ͸ίϐʔ͕ൃੜ͠ͳ͍ • ஋Λมߋ࣌ɺॳΊͯΠϯελϯε͕࡞ΒΕΔ࢓૊ Έ • ͜ͷ࢓૊Έͷ͓͔͛ͰArrayͳͲͰ΋஋ܕΛ࣮ݱ

  15. GenericsΛ༻͍ͨॊೈ͞ • 2ͭͷҾ਺Λswap͢Δؔ਺ • IntܕͷҾ਺ͷΈαϙʔτ • ৼΔ෣͍͸ಉ͕ͩ͡ɺ͋ΒΏΔܕΛαϙʔτͨ͠ ͍..

  16. • GenericsͰղܾ • ܕύϥϝʔλ <T> • ؔ਺, δΣωϦοΫܕ(Class, Struct)ɺ͋ΒΏΔ৔ ໘Ͱ࢖͑Δ

    IUUQTEPDTTXJGUPSHTXJGUCPPL-BOHVBHF(VJEF(FOFSJDTIUNM
  17. ࠷ۙͷSwift • όʔδϣϯΞοϓ͕ΊΜͲ͏ʁ • Φʔϓϯιʔεͱͯ͠ͷػೳڧԽ

  18. • Swift2 to 3ͷΑ͏ͳ஍ࠈ͸ͳ͍ • Swift3ͰObj-CʹҾͬுΒΕͨ࢓༷ΛόοαϦ੾ͬͯ҆ఆ͖ͯͨ͠ • Swift4.1 to 4.2ͷMigration͸਺࣌ؒͰऴΘͬͨɻ

    • XcodeͷMigrationػೳ + ͪΐͬͱͨ͠मਖ਼ͰDone • Ξοϓσʔτͷ஗͍ϥΠϒϥϦ͸Swift3ͰίϯύΠϧ όʔδϣϯΞοϓ͕ΊΜͲ͏ʁ
  19. • จࣈྻͷڧԽ • StringͷCollection TypeԽ • ෳ਺ߦจࣈྻϦςϥϧͷαϙʔτ • Randomؔ਺ͷ࣮૷ •

    ࠓ·ͰCͷؔ਺arc4random_uniform Λ࢖͍͕ͬͯͨɺLinux؀ڥͰ αϙʔτ͞Εͯͳ͍ͨΊ໘౗ͩͬͨ • Dynamic Member Lookup Φʔϓϯιʔεͱͯ͠ͷػೳڧԽ
  20. ͜Ε͔ΒͷSwift • ABI҆ఆԽ • async / await

  21. ABI҆ఆԽ • (ͣͬͱ༏ઌ՝୊͚ͩͲ)Swift5ͷϦϦʔεཁ݅ • ෳ਺ͷSwiftόʔδϣϯͷڞଘ • Ҡߦͷπϥϛ΋ݮΔ • ϥΠϒϥϦ੍࡞ऀ΋خ͍͠ •

    ݱࡏϞδϡʔϧ୯ҐͰSwift3 or 4Λࢦఆͯࠞ͠ࡏͤ͞ Δ͜ͱ͸Մೳ
  22. async / await • ඇಉظॲཧΛಉظॲཧతʹॻ͚Δ • ࠓ·ͰRxSwiftͳͲؔ਺ܕϓϩάϥϛϯάͷΞϓϩʔν ΛಋೖͤͶ͹ͳΒͣ؆୯Ͱ͸ͳ͔ͬͨ • ࣮૷࣌ظ͸·ͩະ֬ఆ

    • KotlinͰ͸͢ͰʹίϧʔνϯಋೖࡁΈ • SwiftͷੜΈͷ਌ΫϦεϥτφʔ͕proposalग़ͨ͠
  23. Before async / await

  24. After (Proposalͷྫ) async / await

  25. Hello! Swift

  26. Swift Playgrounds • iPadͰήʔϜײ֮ͰSwiftΛ৮ΕΔެࣜΞϓϦ IUUQTXXXBQQMFDPNKQTXJGUQMBZHSPVOET

  27. Playground • ϦΞϧλΠϜͰ࣮ߦ͞ΕΔΤσΟλ • ཁXcode

  28. Server Side Swift • UIKitʹڵຯͳ͍ํʹΦεεϝ • Ϗϧυ଎͍͠ɺ؆୯ͳAPIͳΒϗεςΟϯά·Ͱ Ͱ͖ΔϑϨʔϜϫʔΫ΋(ݸਓΞϓϦͷAPI͸SSSͰ࣮૷ͯ͠·͢)

  29. One more things..

  30. ࠷ۙͷXcodeʹ͍ͭͯ

  31. ෳ਺γϛϡϨʔλΛ࢖ͬͨฒྻςετ

  32. Diffʹ৭͕ͭ͘Α͏ʹͳͬͨ!!

  33. Xcode10Ͱ͍ͭʹϚϧνΧʔιϧରԠ!!

  34. Fin