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

Swiftのポイントかいつまみ!

 Swiftのポイントかいつまみ!

個人的に大事だと思うSwiftのポイントかいつまみます。

7d709dd44f86dc8f2b7ddb4c48145dfc?s=128

jollyjoester

August 08, 2015
Tweet

More Decks by jollyjoester

Other Decks in Education

Transcript

  1. Swift2.0͕ग़Δલʹ SwiftͷϙΠϯτ͔͍ͭ·Έʂ SwiftϏΪφʔζษڧձ ୈ̕ճ 2015/08/08 jollyjoester

  2. • ࣣౡҒ೭ʢͳͳ͠·ͻͰΏ͖ʣ • Repro.Inc / ໺ྑΤϯδχΞ • iPhone / Android

    • Java -> Objective-C -> Swift • ੜ·Ε͸ਆಸ઒ɺ஍ݩ͸ઍ༿ɺ ࣗ୐͸ࢁޱ
  3. https://repro.io/

  4. Repro

  5. ࣥචʹࢀՃ͠·ͨ͠ʂ • 2015/04/10ɹٕज़ධ࿦͔ࣾΒൃച ࢒೦ͳ͕ΒSwift1.1࣌୅ Ͱ΋ਖ਼ޡදͱαϯϓϧϓϩάϥϜ͸Swift1.2ରԠ

  6. Introduction • ݸਓతʹେࣄͩͱࢥ͏SwiftͷϙΠϯτ͔͍ͭ·Έ·͢ɻ

  7. TɾOɾC • Constants and Variables • Struct and Class •

    Optionals • Type Constraint • ͓·͚ : Tuples
  8. Constants and Variables • let : immutableʢఆ਺ɺ࠶୅ೖෆՄʣ • var :

    mutableʢม਺ɺ࠶୅ೖՄʣ let : Կ͕خ͍͠ʁ
  9. Constants and Variables let : خ͍͠ͱ͜Ζ • ແବʹՄมͳ෦෼Λগͳ͘͢Δ͜ͱ͕Ͱ͖Δʂ ʢແବʹՄมͳ෦෼͕͋Δͱෳࡶ͕͞૿ͯ͠ෆ۩߹ͷݩʣ ->جຊ͸letͰએݴɻ࠶୅ೖͷඞཁੑ͕ग़͖ͯͨΒvarʹɻ

    ஫ҙ఺ • letͰએݴͨ͠ม਺ʹΦϒδΣΫτ͕୅ೖ͞Ε͍ͯΔ৔߹ɺΦϒδΣ ΫτͷϓϩύςΟ͸มߋͰ͖ͯ͠·͏Αɻ
  10. Struct and Class • struct : ஋౉͠ɺclass : ࢀর౉͠ •

    struct͸ܧঝෆՄ struct : Կ͕خ͍͠ʁ
  11. Struct and Class struct : خ͍͠ͱ͜Ζ • ແବʹՄมͳ෦෼Λগͳ͘͢Δ͜ͱ͕Ͱ͖Δʂ ʢແବʹՄมͳ෦෼͕͋Δͱෳࡶ͕͞૿ͯ͠ෆ۩߹ͷݩʣ ->جຊ͸structͰɻঢ়ଶΛ࣋ͨ͟ΔΛಘͳ͔ͬͨΓܧঝ͕ඞཁͳ৔߹͸

    classͰɻʢܧঝ͸protocolΛ࢖͑͹୅༻Մೳͳ৔߹΋͋ΔΑʣ ஫ҙ఺ • ஋౉͠ͳͷͰͰ͔͍σʔλͷίϐʔ͸ཁ஫ҙ͔΋ʢ࠷దԽ͞ΕͯΔͱ΋ ฉ͘ʣ
  12. Optionals • There is a value, and it equals x

    or • There isn’t value at all Optionals : Կ͕خ͍͠ʁ
  13. Optionals Optionals : خ͍͠ͱ͜Ζ • ແବʹՄมͳ෦෼Λ(ry ->جຊ͸not OptionalͰɻOptionalͰͳ͚Ε͹ͬͯ͜͜nil ೖΔ͔΋ɺɺɺΈ͍ͨͳ͍ٙෆཁ ஫ҙ఺

    • Optionalͷཚ༻͢Δͱ
  14. Type Constraint ܕ੍໿͕ڧ͍->҉໧ͷܕม׵͸ݪଇͰ͖ͳ͍ʂ Type Constraint: خ͍͠ͱ͜Ζ • ແବʹՄม(ry

  15. ͓·͚ɿTuples ෳ਺ͷ஋Λͻͱ·ͱΊʹͰ͖Δ Array΍Dictionaryͱͷҧ͍ • ҟͳΔܕΛೖΕΒΕΔ • ϧʔϓॲཧ͕Ͱ͖ͳ͍ • ஋ͷ௥Ճ࡟আ͕Ͱ͖ͳ͍

  16. ͓·͚ɿTuples ͳΜͰTupleʁ • ࣮͸Swiftͷ஋͸શ෦Tuple • Swiftͷؔ਺͸Ҿ਺΋ฦΓ஋΋ෳ਺औΕΔ->࣮͸྆ํ Tupleͳ͚ͩ

  17. Have a nice Dev!