SwiftUI,Combine Framework,KeyPath - 堅固な関係からSwiftUI への閾値を下げる

0fb0b8c6eecbc8e0a3981501f6a6fea6?s=47 notoroid
January 18, 2020

SwiftUI,Combine Framework,KeyPath - 堅固な関係からSwiftUI への閾値を下げる

SwiftUI を理解するのに欠かせないCombine framework とKeyPath についてのプレゼンテーション。

0fb0b8c6eecbc8e0a3981501f6a6fea6?s=128

notoroid

January 18, 2020
Tweet

Transcript

  1. 4XJGU6* $PNCJOF 'SBNFXPSL ,FZ1BUI ݎݻͳؔ܎͔Β4XJGU6*΁ͷᮢ஋ΛԼ͛Δ

  2. ࣗݾ঺հ

  3. ೳొཁ !OPUPSPJE w J04ΞϓϦ։ൃऀ w ԰߸͍Γ·͢ిࢉاը w !OPUPSPJE w !JSJNBTV

    w Fεϙʔπ
  4. ॆిใࠂ͞Μ #BUUFSFDFJWFS w όοςϦʔϞχλʔ ϢʔςΟϦςΟʔ  w ࠷େ୆ ࣮ػ ϦϞʔτ୆

     w ख࣋ͪͷJ1IPOF͔Βଞʹ͍࣋ͬͯΔ J1IPOF J1BEͳͲͷػثͷόοςϦʔঢ়ଶ֬ ೝՄೳ w ࣗ୐ʹ͋ΔJ1IPOFͷόοςϦʔঢ়ଶ֬ೝՄ ೳ
  5. ॆిใࠂ͞Μ #BUUFSFDFJWFS w </FX>ॆి׬ྃ௨஌ w ॆి׬ྃΛ఻͑ͯ͘ΕΔ௨஌Λ௥Ճɻ w ҎԼʹࢦఆ͢Δ͜ͱͰόοςϦʔ ΛέΞ͢Δ͜ͱ͕Մೳ w

    Կ͔ͱߴ͍J1IPOFΛ௕࣋ͪͤ͞Δͷʹ༗ ༻
  6. ୊໨ w ։ൃͨ͠ΞϓϦͷۙگ w ։ൃελΠϧస׵ͷલ৮Ε  w ,FZ1BUI w $PNCJOFGSBNFXPSL

  7. ։ൃͨ͠ΞϓϦͷۙگ

  8. 0CKFDUJWF$͔Β4XJGU΁ͷҠ২ͨ͠ΞϓϦ

  9. ಈ͘ϦϦʔε͢Δ͜ͱΛ༏ઌ

  10. ݱࡏ͸಺෦ߏ଄Λ੔ཧͭͭ͠ ৽ػೳରԠத

  11. ։ൃελΠϧస׵ͷલ৮Ε

  12. 4XJGU6*ΞϓϦ։ൃͰ ௚໘ͨ͜͠ͱ

  13. ଞ4XJGUͷςΫϊϩδʔΛ ஌Βͳ͍ͱ࡞ۀ͕ετοϓ͢Δ

  14. "QQMFఏڙ4XJGUಛԽͷ ༗໊ϑϨʔϜϫʔΫ͸ͭ $PNCJOFGSBNFXPSL 4XJGU6*

  15. ։ൃऀ૚͕ 0CKFDUJWF$ΑΓ΋ ް͍ 4XJGUʹಛԽͨ͠ϑϨʔϜϫʔΫ͸ ૿͑ͯ͘Δ͔΋

  16. 4XJGU6*Ͱ΋࢖ΘΕ͍ͯΔ 4XJGUͷςΫϊϩδʔΛઆ໌ͯ͠ΈΔ

  17. ຖ೔೦෹ͱͯ͠๨Εͳ͍Α͏ʹ এ͑ͯ΋Α͍͙Β͍Λબͼ·ͨ͠

  18. ,FZ1BUI

  19. ΩʔΛ౉ͯ͠஋ʹ ΞΫηεͰ͖Δػೳ

  20. 4XJGU͔Βݱࡏͷ,FZ1BUIͷܗʹ 0CKFDUJWF$͔Β͋Δػೳͱ͸ผ෺

  21. ,FZQBUI 4XJGUʙ w ܕΛݫີʹѻ͏จࣈྻͰͷΩʔ஋ΞΫηεΛલఏͱ͠ͳ͍ w /40CKFDUඇґଘ 4XJGUͰͷར༻ಛԽ  w ఆٛؒͷύε࿈͕݁Մೳ

    w ഑ྻ΁ͷΞΫηε͕Մೳ
  22. ࢖͍ํ ɾࣗ෼ࣗ਎Λ໌ࣔ͢Δ৔߹ a<Ϋϥε໊>Ωʔ໊\Ωʔ໊^ ɾࣗݾݴٴ͢Δ৔߹͸4FMGΛ࢖༻Ͱ͖Δ a4FMGΩʔ໊ ɾলུܗ͕ڐՄ͞Ε͍ͯΔ aΩʔ໊ ɾ഑ྻ΋ࢦఆͰ͖Δ a<Ϋϥ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͠खஈͱͯ͠ར༻͕࠷ଟ w ҙ֎ʹ1SFWJFXͰͷ༻్͕ଟ͍ ϩέʔϧΛมߋͯ͠ͷ֬ೝ  w 'PS&BDIͰͷ༻్͸άϥϑද͚ࣔͩ࢖༻

  29. $PNCJOFGSBNFXPSL

  30. $PNCJOFGSBNFXPSL w σʔλͷྲྀྔɺྲྀ଎Λ੍ޚ͢ΔͨΊͷϑϨʔϜϫʔΫ w ඇಉظʹ΋ରԠ w σʔλ͸جຊܕɺߏ଄ܕɺྻڍܕɺΦϒδΣΫτΛࢦఆͰ͖Δ w 4XJGUͷػೳΛଟ༻ (FOFSJD

    ,FZ1BUI  w ϑϨʔϜϫʔΫ͕ඞཁ JNQPSU$PNCJOF J04ʙ
  31. Πϝʔδਤ

  32. σʔλ σʔλ σʔλ σʔλͷೖΓޱ

  33. σʔλͷมܗ σʔλC σʔλC σʔλC σʔλC σʔλB σʔλB

  34. σʔλC σʔλC σʔλC σʔλC σʔλB σʔλB 1VCMJTIFST 4VCTDSJCFST 0QFSBUPST σʔλͷมܗ

    σʔλͷมܗɺσʔλͷྲྀ଎ɺσʔλͷྲྀྔͷՃ޻ σʔλͷൃߦऀ σʔλͷߪಡऀ
  35. JNQPSU6*,JU JNQPSU$PNCJOF WBSBOZ$BODFMBCMF4FU"OZ$BODFMMBCMF  MFUQBTTUISPVHI4VCKFDU1BTTUISPVHI4VCKFDU*OU /FWFS  MFUQBTTUISPVHI4VCKFDU1BTTUISPVHI4VCKFDU4USJOH /FWFS 

    QBTTUISPVHI4VCKFDU NBQ\WBMVFJO 4USJOHa WBMVF  ^ TVCTDSJCF QBTTUISPVHI4VCKFDU  QBTTUISPVHI4VCKFDUTJOL\ WBMVF JO QSJOU QBTTUISPVHI4VCKFDUTJOLWBMVFa WBMVF   ^TUPSF JOBOZ$BODFMBCMF  1VCMJTIFS୲౰ 4VCTDSJCFS୲౰ 0QFSBUPS୲౰
  36. σʔλͷൃߦݩ͸छྨ

  37. 1VCMJTIFS݉4VCTDSJCFS 1VCMJTIFSͷछྨᶃᶄ w1BTTUISPVHI4VCKFDU w$VSSFOU7BMVF4VCKFDU 1VCMJTIFS σʔλͷൃߦݩ ͱ4VCKFDU σʔλ ͷߪಡଆ Λ݉ͶΔɺσʔλܕͷม׵ʹ͸ద੾ͳ

    0QFSBUPSTΛ࢖͏ NBQͳͲ
  38. ඇಉظॲཧ 1VCMJTIFSͷछྨᶅ w'VUVSF ϦΫΤετޙɺඇಉظͰσʔλ͕खʹೖΔॲཧ ωοτϫʔΫϦΫΤε τͳͲ ͷσʔλΛड͚औΔͷʹར༻͢ΔɻΤϥʔΛऔಘͰ͖ͣΤϥʔ ͕ฦͬͯ͘Δ͜ͱ΋͋Δ

  39. $PNCJOFGSBNFXPSLͷಛ௃

  40. ΤϥʔϨʔϯͷ༗ແ͕બ΂Δ

  41. σʔλͷೖΓޱ

  42. σʔλͷೖΓޱ

  43. σʔλͷೖΓޱ

  44. MFUQBTTUISPVHI4VCKFDU1BTTUISPVHI4VCKFDU*OU /FWFS  QBTTUISPVHI4VCKFDUTFOE   QBTTUISPVHI4VCKFDUTJOL\ WBMVF JO QSJOU

    QBTTUISPVHI4VCKFDUTJOLWBMVFa WBMVF   ^TUPSF JOBOZ$BODFMBCMF  QBTTUISPVHI4VCKFDUTFOE   MFUDVSSFOU7BMVF4VCKFDU$VSSFOU7BMVF4VCKFDU*OU /FWFS   DVSSFOU7BMVF4VCKFDUTJOL\ WBMVF JO QSJOU DVSSFOU7BMVF4VCKFDUTJOLWBMVFa WBMVF   ^TUPSF JOBOZ$BODFMBCMF  'VUVSF*OU /FWFS\QSPNJTFJO 5ISFBETMFFQ GPS5JNF*OUFSWBM  %JTQBUDI2VFVFHMPCBM BTZOD\ %JTQBUDI2VFVFNBJOBTZOD\ QSPNJTF TVDDFTT   ^ ^ ^ TJOL\ WBMVF JOQSJOU 'VUVSFTJOLWBMVFa WBMVF  ^TUPSF JOBOZ$BODFMBCMF  TVCTDSJCF QBTTUISPVH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