Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

͸Δ;(@_ha1f) ● iOS Developer @ LINE Fukuoka ● WWDCམͪͨʢߦͬͨ͜ͱͳ͍ʣ ● ͍·͕ࡾ೥໨

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

αϯϊθ ● ӈԼͷ΍ͭ Apple Google Facebook ● ΧϦϑΥϧχΞभʢ੢ւ ؛ʣ ● αϯϑϥϯγεί΁͸ CaltrainͰ1࣌ؒ

Slide 8

Slide 8 text

ྑ͍೔ఔͷ੒ా-αϯϊθ௚ߦศ ● ੒ాۭߓͰΊͬͪΌ೔ຊਓiOSΤϯδχΞ ● ඈߦػͰྡͷ੮͕͜͏Ί͍͞Μͩͬͨ

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

AltConfʹ͍ͭͯ

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

WWDC ߦ͖͍ͨʂ

Slide 19

Slide 19 text

Submit!

Slide 20

Slide 20 text

Not selected…

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

AltConfͱ͸ ● Alternative Apple Developer Conference ● WWDCͱಉ͡೔ఔʢ༵ۚ೔͸try! Swiftʣ ● αϯϊθͷɺWWDCձ৔ͷۙ͘Ͱ։࠵

Slide 24

Slide 24 text

WWDC

Slide 25

Slide 25 text

WWDC AltConf

Slide 26

Slide 26 text

WWDC AltConf try!Swift

Slide 27

Slide 27 text

·͡ͰͱͳΓʂ

Slide 28

Slide 28 text

ࣸਅ΋ࡱΕΔ

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

AltConfͷ಺༰ᶄ ● 2 track + LABS + ୤ग़ήʔϜ ● 10෼ͷLT or 45෼ͷsession ● ࣗ෼͸LT

Slide 33

Slide 33 text

ͳ͔ͥग़Δ͓ञ ● ே͸ே৯ʴίʔώʔ͕ͰΔ ● ༦ํ͸ञ͕ग़Δ ● શ෦ແྉ

Slide 34

Slide 34 text

ొஃʹ͍ͭͯ

Slide 35

Slide 35 text

AltConfͰͷొஃ಺༰(10෼) ● A story of Mysterious Asian Strings ● ೔ຊޠ/λΠޠ/ؖࠃޠͷจࣈͷѻ͍ʹؔ͢ΔςΫχοΫ ● ӳޠ࿩ऀ͸શ֯൒֯ɺม׵ͳͲͷ஌͕ࣝͳ͍ͷͰɺͦͷ঺հ

Slide 36

Slide 36 text

AltConfͷCfP ● CfPʹग़ͯ͠ɺબΜͰ΋Β͏ܗࣜ ● ग़ͨ͠ͷ͸݄̑Լ०ʢకΊ੾ΓΪϦΪϦʣ

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

ొஃ

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

ͦͯ͠ɺࣄ݅͸ىͬͨ͜

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

100.8°F

Slide 48

Slide 48 text

100.8°F ● ઁࢯ38.2 ● ׬શʹ೤

Slide 49

Slide 49 text

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

Slide 50

Slide 50 text

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

Slide 51

Slide 51 text

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

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

఺ణ

Slide 56

Slide 56 text

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

Slide 57

Slide 57 text

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

Slide 58

Slide 58 text

·ͱΊ

Slide 59

Slide 59 text

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

Slide 60

Slide 60 text

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

Slide 61

Slide 61 text

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

Slide 62

Slide 62 text

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

Slide 63

Slide 63 text

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

Slide 64

Slide 64 text

THANK YOU LINE Fukuokaɹ͸Δ;(@_ha1f) Follow @ha1f on Twitter! Follow ͸Δ;'s ΤϯδχΞ vlog on YouTube!

Slide 65

Slide 65 text

A story of Mysterious Asian Strings (for iOS) AltConf SanJose 2019 LINE Fukuoka Tomoki Yamaguchi a.k.a. @ha1f

Slide 66

Slide 66 text

Tomoki Yamaguchi @_ha1f ● iOS Developer from Japan! ● Working for LINE Fukuoka (Communication application) ● Call me “half”

Slide 67

Slide 67 text

Hello Asian World. উ֞ೞࣁਃ สวัสดีครับ ͜Μʹͪ͸ 㟬޷

Slide 68

Slide 68 text

How do you work with asian characters? ● Even Amazon, Apple have problems ϑΟϧλʔ filter Ωϟϯηϧ Cancel

Slide 69

Slide 69 text

Full-width, Half-width ● Most Japanese, Chinese, Korean characters are full-width AB12 ̖̗̍̎ ͑ͼұ್ ● Alphabets, numbers have both styles

Slide 70

Slide 70 text

Today’s purpose ● Tell about some techniques for asian characters ● Knowing a little will help you!

Slide 71

Slide 71 text

Agenda • Text layout (current) • Character counting • Text validation

Slide 72

Slide 72 text

Vertical Form ● Japanese, Chinese, Korean can be represented with vertical form ● Supported by Kindle ॎ ॻ ͖ ͷ ৔ ߹ ͸ ӈ ͔ Β ࠨ ʹ ಡ Έ · ͢ ԣॻ͖ͷ৔߹͸ ࠨ͔Βӈʹ ಡΈ·͢ Vertical Scroll Horizontal Scroll

Slide 73

Slide 73 text

Thai language sometimes exceeds UILabel ● CALayer.clipToBounds will cut them ● We should not set “clipToBounds” ● Basically Thai language specific

Slide 74

Slide 74 text

Agenda • Text layout • Character counting • Text validation

Slide 75

Slide 75 text

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

Slide 76

Slide 76 text

Counting alphabet characters is easy ● Most counting methods return the same value

Slide 77

Slide 77 text

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)

Slide 78

Slide 78 text

Thai language counting How long is this String? ำำำำำำำำำำำำำำำำำำ

Slide 79

Slide 79 text

Thai language counting ● We should also restrict with memory size ● Grapheme cluster counting returns 1

Slide 80

Slide 80 text

Agenda • Text layout • Character counting • Text validation

Slide 81

Slide 81 text

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 }

Slide 82

Slide 82 text

Character conversion ● One character can be a combination of multiple characters ● Even insert / delete don’t change the characters count ● Works like replacing

Slide 83

Slide 83 text

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 }

Slide 84

Slide 84 text

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 }

Slide 85

Slide 85 text

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

Slide 86

Slide 86 text

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!! ͔͍͸ͭ͠Ό → ։ൃऀ

Slide 87

Slide 87 text

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)) } }

Slide 88

Slide 88 text

Conclusion 1. Be careful for character’s width and height 2. Be careful for counting strategy 3. Don’t block input during editing

Slide 89

Slide 89 text

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