ReactiveCocoaで作る快適な登録フォーム

A003bc0b49c7e5adf746b6d73cb57956?s=47 shoby
July 11, 2016

 ReactiveCocoaで作る快適な登録フォーム

Melon.swiftの発表資料です。
http://fablic.connpass.com/event/35407/

A003bc0b49c7e5adf746b6d73cb57956?s=128

shoby

July 11, 2016
Tweet

Transcript

  1. 3FBDUJWF$PDPBͰ࡞Δ շదͳొ࿥ϑΥʔϜ גࣜձࣾ'BCMJD TIPCZ

  2. ࣗݾ঺հ 

  3. ࣗݾ঺հ w TIPCZ w 'BCMJD JOD w J043VCZPO3BJMTը૾ॲཧ w ϝϩϯ೶Ոͷଉࢠ

    
  4. ֓ཁ 

  5. ֓ཁ w շదͳొ࿥ϑΥʔϜͱ͸ w ೖྗ஋ͷϦΞϧλΠϜόϦσʔγϣϯ w 3FBDUJWF$PDPBʹΑΔ5FYUมԽͷݕ஌ w TUSVDUʹΑΔΤϥʔͷදݱ w

    ϑϦϧͰͷվળͷ݁Ռ 
  6. շదͳొ࿥ϑΥʔϜͱ͸ 

  7. շదͳొ࿥ϑΥʔϜͱ͸ w গͳ͍ೖྗͰࡁΉ w ༣ศ൪߸͔ΒॅॴΛิ׬ w ೖྗܗ͕ࣜ෼͔Δ w 6*1JDLFS7JFX6*%BUF1JDLFS w

    ,FZCPBSE5ZQF w ೖྗ஋͕ϦΞϧλΠϜͰνΣοΫ͞ΕΔ 
  8. շదͳొ࿥ϑΥʔϜͱ͸ w গͳ͍ೖྗͰࡁΉ w ༣ศ൪߸͔ΒॅॴΛิ׬ w ೖྗܗ͕ࣜ෼͔Δ w 6*1JDLFS7JFX6*%BUF1JDLFS w

    ,FZCPBSE5ZQF w ೖྗ஋͕ϦΞϧλΠϜͰνΣοΫ͞ΕΔ 
  9. 5FYU'JFMEͷ ϦΞϧλΠϜόϦσʔγϣϯ 

  10. 5FYU'JFMEͷϦΞϧλΠϜόϦσʔγϣϯ w ঢ়ଶ͸ҎԼͷͭ w ະೖྗʢ1MBDF)PMEFSΛදࣔ͢Δʣ w ೖྗதʢԿ΋දࣔ͠ͳ͍ʣ w 0,ʢ✅Λදࣔʣ w

    Τϥʔʢ⚠Λදࣔʣ w 5FYUͷมԽͱɺೖྗ׬ྃͰόϦσʔγϣϯ 
  11. 5FYU'JFMEͷϦΞϧλΠϜόϦσʔγϣϯ  ະೖྗ ೖྗத Τϥʔ ⚠ 0, ✅ ೖྗ։࢝ 5FYUͷมԽ

    ೖྗ։࢝ όϦσʔγϣϯ Τϥʔ ਖ਼ৗʹ׬ྃ 5FYUͷมԽ
  12. 5FYU'JFMEͷϦΞϧλΠϜόϦσʔγϣϯ w ೖྗऴྃˠUFYU'JFME%JE&OE&EJUJOH w 5FYUͷมԽˠ3FBDUJWF$PDPB w UFYU'JFMETIPVME$IBOHF$IBSBDUFST*O3BOHFSFQMB DFNFOU4USJOHͰϋϯυϦϯά͸͠ΜͲ͍ 

  13. 3FBDUJWF$PDPBʹΑΔ 5FYUมԽͷݕ஌ 

  14. 3FBDUJWF$PDPBʹΑΔ5FYUมԽͷݕ஌ var disposables: [Disposable] = [] textFields.forEach { textField in

    let disposable = textField.rac_textSignal().toSignalProducer().skip(1).startWithNext { text in do { try self.validate(text: text, textField: textField) } catch let error { // ΤϥʔϋϯυϦϯά } } disposables.append(disposable) } 
  15. 3FBDUJWF$PDPBʹΑΔ5FYUมԽͷݕ஌ var disposables: [Disposable] = [] textFields.forEach { textField in

    let disposable = textField.rac_textSignal().toSignalProducer().skip(1).startWithNext { text in do { try self.validate(text: text, textField: textField) } catch let error { // ΤϥʔϋϯυϦϯά } } disposables.append(disposable) }  ॳճͷTJHOBMΛແࢹ͢Δ͜ͱͰ ະೖྗͱೖྗதΛ۠ผ
  16. TUSVDUʹΑΔΤϥʔͷදݱ 

  17. TUSVDUʹΑΔΤϥʔͷදݱ w &SSPS5ZQF͸1SPUPDPMͳͷͰTUSVDUͰ΋0, w DMBTT΋࢖͑Δ w όϦσʔγϣϯΤϥʔʹ͸TUSVDU͕ศར w ΤϥʔͷछྨΛ۠ผ͢Δඞཁ͕ͳ͍ w

    Τϥʔϝοηʔδͱ෇Ճ৘ใ͚ͩ 
  18. TUSVDUʹΑΔΤϥʔͷදݱ struct ValidationError: ErrorType { let message: String let showWhileEditing:

    Bool }  ϝοηʔδͱ ฤूத΋දࣔ͢Δ͔Ͳ͏͔ͷϑϥάͷΈ
  19. ϑϦϧͰͷվળͷ݁Ռ 

  20. 

  21. ϑϦϧͰͷվળͷ݁Ռ w ΞΧ΢ϯτొ࿥཰͕Ξοϓ 

  22. ·ͱΊ 

  23. ·ͱΊ w গͳ͍ೖྗͰࡁΈɺೖྗܗ͕ࣜ෼͔ΓɺϦΞ ϧλΠϜͰνΣοΫ͞ΕΔϑΥʔϜ͸շద w ϦΞϧλΠϜνΣοΫʹ͸5FYUͷมԽͱೖྗ ׬ྃͷλΠϛϯάͰόϦσʔγϣϯ͢Δ w 3FBDUJWF$PDPBΛ࢖͏ͱ5FYUมԽͷݕ஌ָ͕ w

    όϦσʔγϣϯΤϥʔ͸TUSVDUΛ࢖͏ͱྑ͍ w ϑϦϧͷ৔߹ɺొ࿥ϑΥʔϜվળͰొ࿥཰͕ ্͕ͬͨ