AltConf report - Hakata.swift #8

AltConf report - Hakata.swift #8

21a81f53752bceb7a7eb0ed20cd676a7?s=128

はるふ

June 25, 2019
Tweet

Transcript

  1. AltConf 2019 Ϩϙʔτ ୈ8ճ HAKATA.swift LINE Fukuoka Corporation ͸Δ;(@_ha1f)

  2. ͸Δ;(@_ha1f) • iOS Developer @ LINE Fukuoka • WWDCམͪͨʢߦͬͨ͜ͱͳ͍ʣ •

    ͍·͕ࡾ೥໨
  3. ࠷ۙͷۀ຿ʹΧελϜελϯϓ • จࣈΛηοτͰ͖Δελϯϓ • ΋ͪΖΜiOS෦෼ͷΈ • https://engineering.linecorp.com/ja/blog/product-story-01-custom-sticker/

  4. Topic • AltConf@SanJoseʹࢀՃ • ӳޠͰొஃ͖ͯ͠·ͨ͠ʂ • αϯϊθશൠʹ͍ͭͯϨϙʔτ͠·͢ʂ

  5. Agenda • αϯϊθͰͷੜ׆ʹ͍ͭͯ • AltConfʹ͍ͭͯ • ొஃʹ͍ͭͯ • ͓·͚

  6. αϯϊθͰͷੜ׆ʹ͍ͭͯ

  7. αϯϊθ • ӈԼͷ΍ͭ Apple Google Facebook • ΧϦϑΥϧχΞभʢ੢ւ ؛ʣ •

    αϯϑϥϯγεί΁͸ CaltrainͰ1࣌ؒ
  8. ྑ͍೔ఔͷ੒ా-αϯϊθ௚ߦศ • ੒ాۭߓͰΊͬͪΌ೔ຊਓiOSΤϯδχΞ • ඈߦػͰྡͷ੮͕͜͏Ί͍͞Μͩͬͨ

  9. αϯϊθͬͯͲΜͳͱ͜ʁ • ాࣷ • Uber͕ͳ͍ͱੜ͖ΒΕͳ͍ • ຖ೔շ੖ɺ೔͕ࠩ͠ڧ͍ ɹʢଟ෼஍໘Ͱ໨ۄম͖ম͚Δʣ Apple ParkͰ๧ࢠങͬͨ

  10. αϯϊθͷؾԹ • ன͸ॵͯ͘໷͸ྋ͍͠ • ͳΜͱ࠷ߴؾԹ100౓ʂ

  11. αϯϊθͷؾԹ • ன͸ॵͯ͘໷͸ྋ͍͠ • ͳΜͱ࠷ߴؾԹ100౓ʂ • ͱ͍͏ͷ͸৑ஊͰϗϯτ͸ઁࢯ38౓

  12. https://amzn.to/2xa2eUF SIMΧʔυ • ద౰ʹAmazonͰങ͍ͬͯͬͨ • 10೔ؒLTE࢖͍์୊ϓϥϯ2990ԁ

  13. α΢εϕΠҿΈձ • ϕΠΤϦΞࡏॅͷ೔ຊਓͱͷަྲྀ • ຖ݄΍ͬͯΔΒ͍͠

  14. ৯ࣄ • ͏·͍ɺͰ͔͍ɺߴ͍ ʢϋϯόʔΨʔͰ1500ԁͱ͔ʣ • ଞࠃͷྉཧଟ͍

  15. ϗςϧʹHomewood Suites by Hilton • WWDCظؒத͚ͩΫιߴ͍ ɹʢ1ധ2.5ສԁͩͬͨʣ • ձ৔͔ΒిंͰ30෼͙Β͍ ɹʢۙ͘͸׬ചʣ

    ே৯෇͖
  16. AltConfʹ͍ͭͯ

  17. None
  18. WWDC ߦ͖͍ͨʂ

  19. Submit!

  20. Not selected…

  21. None
  22. None
  23. AltConfͱ͸ • Alternative Apple Developer Conference • WWDCͱಉ͡೔ఔʢ༵ۚ೔͸try! Swiftʣ •

    αϯϊθͷɺWWDCձ৔ͷۙ͘Ͱ։࠵
  24. WWDC

  25. WWDC AltConf

  26. WWDC AltConf try!Swift

  27. ·͡ͰͱͳΓʂ

  28. ࣸਅ΋ࡱΕΔ

  29. Wi-Fi΋…… WWDC͕ ࠷େڧ౓

  30. ࢀՃඅ༻ • ࢀՃඅ͸0ԁʢάοζͳ͠ʣ or 7000ԁʢάοζͳ͠ʣ ɹor 4ສԁʢάοζ͋Γʣ • WWDCͷࢀՃऀͱ͔༡ͼʹདྷΔʢ࣮࣭ೖ৔νΣοΫͳ͠ʣ

  31. AltConfͷ಺༰ᶃ • ॳ೔͸WWDCͷύϒϦοΫϏϡʔΠϯά • ̎೔໨Ҏ͕߱ηογϣϯ

  32. AltConfͷ಺༰ᶄ • 2 track + LABS + ୤ग़ήʔϜ • 10෼ͷLT

    or 45෼ͷsession • ࣗ෼͸LT
  33. ͳ͔ͥग़Δ͓ञ • ே͸ே৯ʴίʔώʔ͕ͰΔ • ༦ํ͸ञ͕ग़Δ • શ෦ແྉ

  34. ొஃʹ͍ͭͯ

  35. AltConfͰͷొஃ಺༰(10෼) • A story of Mysterious Asian Strings • ೔ຊޠ/λΠޠ/ؖࠃޠͷจࣈͷѻ͍ʹؔ͢ΔςΫχοΫ

    • ӳޠ࿩ऀ͸શ֯൒֯ɺม׵ͳͲͷ஌͕ࣝͳ͍ͷͰɺͦͷ঺հ
  36. AltConfͷCfP • CfPʹग़ͯ͠ɺબΜͰ΋Β͏ܗࣜ • ग़ͨ͠ͷ͸݄̑Լ०ʢకΊ੾ΓΪϦΪϦʣ

  37. Yours is among those selected! • ϝʔϧ͕དྷͯɺإࣸਅͱ͔ͷఏग़ΛٻΊΒΕͨ

  38. AltConfͷCfPͷ౰બޙ • εΫϦʔϯͷॎԣൺͱ͔ڭ͑ͯ͘ΕΔ • ਐߦͷਓ͕ಡΉ঺հจΛࣄલʹఏग़͢Δ • ࢿྉͷࣄલఏग़ͳͲ͸ͳ͠

  39. ొஃ௚લ • AltConfࣗମ͸ਓ਺গͳΊʢWWDCͷϏσΦݟͯΔਓ͕ଟ͍ʣ

  40. ొஃ

  41. ొஃͷ݁Ռ • ࣭໰΋͕͋ͬͨͱΓ͋͑ͣͳΜͱ͔ͳͬͨʂ • ൓Ԡ΋΋Β͑ͨ

  42. ӳޠྗʁ • ཹֶɾւ֎ࡏॅܦݧͳ͠ • େֶೖࢼͰษڧ ʴ ࣾձਓʹͳ͔ͬͯΒձࣾͰ • TOEIC 855ʢ1೥લ͸770ʣ

  43. ͦͯ͠ɺࣄ݅͸ىͬͨ͜

  44. ొஃޙ…… ໦༵ʹొஃͨ͠

  45. ༵ۚͷ໷ • פؾ͕ͨ͠ • ࣮͸Ր༵͔Β޴͕௧͔ͬͨ • ొஃʹ޲͚ͯͷਫ਼ਆྗͰ଱͑ͯͨͷ͕੾Εͨ

  46. ౔༵೔ Mission1: ମԹͷ֬ೝ ମԹܭͳ͍ʁ ͳ͍Αʁମௐѱ͍ͷʁ ೤ͬΆ͍ΜΑͶ ͡Ό͋ελοϑʹങ͍ʹߦ͔ ͤΔΑɻ܅࣋ͪ΍͚Ͳ ͋Γ͕ͱ

  47. 100.8°F

  48. 100.8°F • ઁࢯ38.2 • ׬શʹ೤

  49. ϗϯτ͸΋ͬͱ΋ͬͱ௕͍ɻ Mission2: อݥձࣾ΁ి࿩ පӃߦ͖͍ͨ ʙʙʹߦ͍ͬͯͩ͘͞ ͓͚ ཱͯସ͑Δ͔Β͓ۚݱ஍Ͱ෷ Θͳ͍͍ͯ͘Α ఱ࠽

  50. ౔༵ͳͷͰEmergency͔͍͋ͯ͠ͳ͍ Regional Medical Center

  51. όʔίʔυΛ͸ΊΒΕ·͢

  52. ໰਍ͷޙɺݕ߲ࠪ໨ҰཡΛ΋Β͍·͢ • Θ͔Γ΍͍͢

  53. ϗϯτ͸΋ͬͱ΋ͬͱ௕͍ɻ Mission3: ҩऀͱͷձ࿩ ೤ɻ޴௧͍ @L#P{$@#P{$:{P@# ͳΔ΄Ͳ $:#{}P@{%@}_P@#!_+%(#! @)_%@#:$$LP@#{$L#@{ ׬શʹཧղͨ͠

  54. ΊͬͪΌΉ͍ͣ ͚ͲͳΜͱ͔ཧղͰ͖Δ·Ͱ આ໌ͯ͘͠Εͨʂʂʂ

  55. ఺ణ

  56. ༀہ·Ͱ΋Uberɻ7000ԁ͙Β͍Ͱͨ͠ɻ ॲํᝦͱༀ ॲํᝦ ༀ

  57. පӃ • ࣄલʹΊͬͪΌઆ໌ͯ͘͠ΕΔʢinformed consentʣ ɹɹɹɹ˞ཧղͰ͖Δ͔͸ผ • A4࢛ຕɺΊͬͪΌஸೡͳ਍அॻ΋Β͑ͨ • 4͙࣌ؒΒ͍͸Έͨ΄͏͕ྑ͍ •

    ؼࠃޙʹ΋පӃߦͬͨ
  58. ·ͱΊ

  59. ·͡ͰࢀՃͯ͠Α͔ͬͨʂ • ೤ग़ͯ΋΄ΜͱʹߦͬͯΑ͔ͬͨ • ϦΞϧλΠϜͰηογϣϯΛݟΕΔɺٞ࿦Ͱ͖Δ ɹɹʢWWDCࢀՃऀͱ΋ʣ • ೤ྔΛײ͡ΒΕΔʂʂ

  60. ͓͢͢Ί࣋ͪ෺ • ๧ࢠɺαϯάϥε • betaͷmacOS, iOSΛೖΕͯ΋Α͍୺຤ • SIMΧʔυɺ௺੾ΓɺମԹܭɺༀɺอݥ

  61. On YouTube Vlog • ΞϝϦΧͰͪΐͬͱ౤ߘͨ͠ • https://www.youtube.com/channel/ UC20AZKltEpdZkKYalgBhLHA • νϟϯωϧొ࿥ɺߴධՁ΋ΑΖ͘͠Ͷʂ

  62. https://youtu.be/D7cqkOx3hsg Other videos… AltConfͷײ૝ΠϯλϏϡʔ

  63. https://youtu.be/SllqSFylicY Other videos… lovee͞Μ΋WWDCΠϯλϏϡʔ

  64. THANK YOU LINE Fukuokaɹ͸Δ;(@_ha1f) Follow @ha1f on Twitter! Follow ͸Δ;'s

    ΤϯδχΞ vlog on YouTube!
  65. A story of Mysterious Asian Strings (for iOS) AltConf SanJose

    2019 LINE Fukuoka Tomoki Yamaguchi a.k.a. @ha1f
  66. Tomoki Yamaguchi @_ha1f • iOS Developer from Japan! • Working

    for LINE Fukuoka (Communication application) • Call me “half”
  67. Hello Asian World. উ֞ೞࣁਃ สวัสดีครับ ͜Μʹͪ͸ 㟬޷

  68. How do you work with asian characters? • Even Amazon,

    Apple have problems ϑΟϧλʔ filter Ωϟϯηϧ Cancel
  69. Full-width, Half-width • Most Japanese, Chinese, Korean characters are full-width

    AB12 ̖̗̍̎ ͑ͼұ್ • Alphabets, numbers have both styles
  70. Today’s purpose • Tell about some techniques for asian characters

    • Knowing a little will help you!
  71. Agenda • Text layout (current) • Character counting • Text

    validation
  72. Vertical Form • Japanese, Chinese, Korean can be represented with

    vertical form • Supported by Kindle ॎ ॻ ͖ ͷ ৔ ߹ ͸ ӈ ͔ Β ࠨ ʹ ಡ Έ · ͢ ԣॻ͖ͷ৔߹͸ ࠨ͔Βӈʹ ಡΈ·͢ Vertical Scroll Horizontal Scroll
  73. Thai language sometimes exceeds UILabel • CALayer.clipToBounds will cut them

    • We should not set “clipToBounds” • Basically Thai language specific
  74. Agenda • Text layout • Character counting • Text validation

  75. Counting characters • There are many ways to count characters

    e.g. UTF-8, grapheme cluster, unicode scalar, width, … • Apple’s default (String.count) is grapheme cluster
  76. Counting alphabet characters is easy • Most counting methods return

    the same value
  77. Asian Strings are not so easy • Each method returns

    a different length • “.count” is more likely to return what you expect! i.e. user-friendly (recommended)
  78. Thai language counting How long is this String? ำำำำำำำำำำำำำำำำำำ

  79. Thai language counting • We should also restrict with memory

    size • Grapheme cluster counting returns 1
  80. Agenda • Text layout • Character counting • Text validation

  81. Can you find a bug? Suppose we want to prevent

    from inputting text longer than 3 characters // Forbid text longer than 3 func textField( _ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String ) -> Bool { return (textField.text?.count ?? 0) < 3 }
  82. Character conversion • One character can be a combination of

    multiple characters • Even insert / delete don’t change the characters count • Works like replacing
  83. We have to validate String after change • We have

    to check characters limit after change func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { let currentText = textField.text ?? "" let newText = (currentText as NSString) .replacingCharacters(in: range, with: string) return newText.count <= 3 }
  84. Even this has a bug! func textField(_ textField: UITextField, shouldChangeCharactersIn

    range: NSRange, replacementString string: String) -> Bool { let currentText = textField.text ?? "" let newText = (currentText as NSString) .replacingCharacters(in: range, with: string) return newText.count <= 3 }
  85. Even this has a bug! func textField(_ textField: UITextField, shouldChangeCharactersIn

    range: NSRange, replacementString string: String) -> Bool { let currentText = textField.text ?? "" let newText = (currentText as NSString) .replacingCharacters(in: range, with: string) return newText.count <= 3 } Let’s check the value here
  86. Result of “replacingCharacters” can be wrong • Input and Output

    do not match • The result can be shortened after confirmation Don’t trust intermediate text Don’t prevent input during editing!! ͔͍͸ͭ͠Ό → ։ൃऀ
  87. We have to validate String after change • We have

    to limit characters after confirmation override func viewDidLoad() { super.viewDidLoad() textField.addTarget(self, action: #selector(handleChange(_:)), for: .editingDidEnd) } @objc func handleChange(_ textField: UITextField) { textField.text = textField.text.map { String($0.prefix(3)) } }
  88. Conclusion 1. Be careful for character’s width and height 2.

    Be careful for counting strategy 3. Don’t block input during editing
  89. THANK YOU LINE Fukuokaɹ͸Δ;(@_ha1f) Follow @ha1f on Twitter!