初めての Source of Truth / Brief Intro to Source of Truth

初めての Source of Truth / Brief Intro to Source of Truth

Af64bc38c0ffcfcabdf430759ee491ce?s=128

Elvis Shi

July 03, 2020
Tweet

Transcript

  1. ॳΊͯͷ4PVSDFPG5SVUI f o r  : 6 . & .

    *  T X J G U     d Έ Μ ͳ Ͱ ৼ Γ ฦ Ζ ͏ ɺ 8 8 % $ d ?
  2. } var employedBy = "YUMEMI Inc." var job = "iOS

    Tech Lead" var favoriteLanguage = "Swift" var twitter = "@lovee" var qiita = "lovee" var github = "el-hoshino" var additionalInfo = """ ࣾ಺ϏσΦձٞͰ Vzoomer ૿΍͠·ͨ͠ʂ """ final class Me: Developable, Talkable {
  3. 4PVSDFPG5SVUI ਅ࣮ ιʔείʔυ

  4. 4PVSDF ΋ͱɺݯɺىݯ˗෺ࣄ͕࢝·ͬͨ৔ॴ΍ɺͦͷݩͱ ͳͬͨਓ΍෺ࣄɻ ʤ৘ใͷʥൃ৴ݩɺ৘ใݯɺফଉے˗ʲ༻๏ʳ௨ྫ TPVSDFT ʬ஍ֶʭʤ઒ͳͲͷʥਫݯʢ஍ʣ ʬిؾʭʤిքޮՌܕτϥϯδελͷʥιʔε ʬίʭιʔεɾίʔυ˗ʲಉʳTPVSDFDPEF ग़యɿ<ӳࣙ࿠> IUUQTFPXBMDDPKQTFBSDI

    RTPVSDF
  5. 4PVSDFPG5SVUI ਅ࣮ ىݯ ৘ใݯ

  6. 4PVSDFPG5SVUI ৗʹҰͭͰ͋Δ΂͖ʢ4JOHMF4PVSDFPG5SVUIʣ w୭͕͜ͷσʔλΛॴ༗͍ͯ͠Δ͔ ඞཁʹԠͯ͡ద੾ͳڞ༗ΛબͿ wڞ༗ઌͰ஋͕มߋՄೳ͔Ͳ͏͔

  7. -JTU 7JFX %FUBJM 7JFX isOn: Bool isOn: Bool ભҠ 4PVSDF

    PG5SVUI 4PVSDF PG5SVUI JT0O͸ͦΕͧΕͷϏϡʔͷ ݻ༗ঢ়ଶͷͨΊɺ ͦΕͧΕಠཱͨ͠4PVSDF PG5SVUIʹͳΔ
  8. -JTU 7JFX %FUBJM 7JFX name: String name: String ಉ͡৘ใ͕ෳ਺Օॴʹଘࡏ͢Δʂ มߋ͕ڞ༗͞Εͳ͍

    ͲΕ͕ਖ਼͍͔͕͠Θ͔Βͳ͍ ৘ใͷ෼ࢄ؅ཧɺμ ϝɻઈର ભҠ
  9. -JTU 7JFX %FUBJM 7JFX name: String ભҠ ࢀর 4PVSDF PG5SVUI

    3FGFSFODF PG5SVUI
  10. -JTU 7JFX %FUBJM 7JFX ભҠ ࢀর 4PNFXIFSF name: String 4PVSDF

    PG5SVUI 3FGFSFODF PG5SVUI 3FGFSFODF PG5SVUI
  11. -JTU 7JFX %FUBJM 7JFX "QQ 4DFOF -JTU 7JFX %FUBJM 7JFX

    4DFOF App Data Scene Data Scene Data List View Data List View Data ભҠ ࢀর
  12. Մมσʔλ σʔλ͕஋ܕ ʢString΍Intʣ σʔλ͕ࢀরܕ ʢObservableObjectʣ ιʔε @State var @StateObject var

    ෆՄมڞ༗ let let Մมڞ༗ @Binding var @ObservedObject var ෆՄมσʔλ σʔλ͕஋ܕ ʢString΍Intʣ σʔλ͕ࢀরܕ ʢObservableObjectʣ ιʔε let let ෆՄมڞ༗ let let Մมڞ༗ /" /" NEW
  13. Մมσʔλ σʔλ͕஋ܕ ʢString΍Intʣ σʔλ͕ࢀরܕ ʢObservableObjectʣ ιʔε @State var @StateObject var

    ෆՄมڞ༗ let let Մมڞ༗ @Binding var @ObservedObject var ෆՄมσʔλ σʔλ͕஋ܕ ʢString΍Intʣ σʔλ͕ࢀরܕ ʢObservableObjectʣ ιʔε let let ෆՄมڞ༗ let let Մมڞ༗ /" /" NEW ࣗ෼͸ͦͷσʔλΛม͑ͳ͍͚Ͳɺ ผͷը໘ʹΑͬͯͦͷσʔλ͕มΘͬͨΒ ࣗ෼Λߋ৽͠ͳ͍ͱ͍͚ͳ͍ɻ ͦΕͰ΋letͳͷʁ! ͦ͏Ͱ͢ʂ
  14. 6*,JU6*7JFX 4XJGU6*7JFX ܕ ࢀরܕ ஋ܕ ੜ੒࣌ظ Ϗϡʔ࡞੒࣌ ඳըߋ৽։࢝࣌ ഁغ࣌ظ ϏϡʔώΤϥϧΩʔ͔Β

    ͳ͘ͳͬͨͱ͖ ඳըߋ৽ऴ͙ྃ࣌͢ ੜଘظؒ جຊ௕͍ ඇৗʹ୹͍ ੜ੒ճ਺ جຊগͳ͍ ඇৗʹଟ͍ ຊ࣭ ϏϡʔΦϒδΣΫτͦͷ΋ͷ ϏϡʔͷϨϯμϦϯάઆ໌
  15. 6*,JU6*7JFX 4XJGU6*7JFX ܕ ࢀরܕ ஋ܕ ੜ੒࣌ظ Ϗϡʔ࡞੒࣌ ඳըߋ৽։࢝࣌ ഁغ࣌ظ ϏϡʔώΤϥϧΩʔ͔Β

    ͳ͘ͳͬͨͱ͖ ඳըߋ৽ऴ͙ྃ࣌͢ ੜଘظؒ جຊ௕͍ ඇৗʹ୹͍ ੜ੒ճ਺ جຊগͳ͍ ඇৗʹଟ͍ ຊ࣭ ϏϡʔΦϒδΣΫτͦͷ΋ͷ ϏϡʔͷϨϯμϦϯάઆ໌ ඞཁʹͳͬͨͱ͖ ౎౓ੜ੒͞ΕΔͨΊ letͰ΋ਖ਼͘͠ ϨϯμϦϯά͞ΕΔ" ͋Εʁ͡Ό͋ 4PVSDFPG5SVUI ͷϏϡʔ͸ʁ
  16. Մมσʔλ σʔλ͕஋ܕ ʢString΍Intʣ σʔλ͕ࢀরܕ ʢObservableObjectʣ ιʔε @State var @StateObject var

    ෆՄมڞ༗ let let Մมڞ༗ @Binding var @ObservedObject var ෆՄมσʔλ σʔλ͕஋ܕ ʢString΍Intʣ σʔλ͕ࢀরܕ ʢObservableObjectʣ ιʔε let let ෆՄมڞ༗ let let Մมڞ༗ /" /"
  17. !4UBUFͱ!4UBUF0CKFDUͷҙٛ σʔλ͕ߋ৽͞Εͨͱ͖ɺࢀরΛ࣋ͭΠϯελϯεʹ ௨஌Λग़͢ 4XJGU6*ʹ͓͍ͯɺViewߏ଄ମͱ͸ผͷ৔ॴͰ֨ೲ ͠ɺσʔλͷੜଘظؒΛ7JFXͷϥΠϑαΠΫϧ͔Β ղ์ -JTU 7JFX 4XJGU6* isOn:

    Bool @State
  18. ·ͱΊ w 4PVSDFPG5SVUIΛৗʹ৺͕͚Α͏ w ద੾ͳσʔλએݴͰ4PVSDFPG5SVUIΛҡ࣋͠Α͏ w 4XJGU6*ͷ7JFX͸ͨͩͷϨϯμϦϯάઆ໌ʂ 4XJGU6*ʹݶΒͣ ͲΜͳઃܭʹ΋௨༻ͦ͠͏

  19. ͞Βʹৄ͍͠৘ใʹ͍ͭͯ w 88%$ηογϣϯ౳ w IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOTXJGUVJTUBUF BOEEBUBqPX w IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXED w IUUQTEFWFMPQFSBQQMFDPNWJEFPTQMBZXXED

    w ಛʹ!&OWJSPONFOU0CKFDUɺ!"QQ4UPSBHF΍0CTFSWBCMF 0CKFDUͳͲͷઆ໌͸ׂѪ͍͠ΔͷͰɺؾʹͳΔํ͸ͥͻ্ͷϦϯ ΫΛʂ