Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
1年前に作った物と同じ目的のライブラリをまたSwift 3で作ってみた
Search
fromkk
November 29, 2016
Technology
0
1.2k
1年前に作った物と同じ目的のライブラリをまたSwift 3で作ってみた
TMValidatorを作った経験を活かしてSwift 3で同じ目的のライブラリを作ってみました。
fromkk
November 29, 2016
Tweet
Share
More Decks by fromkk
See All by fromkk
note社の全員野球で品質向上活動について / note_qa_challenge #iOS_test_teatime
fromkk
3
1.9k
1年分のデータが見たいと言われてやったこと/yearly_data_with_note
fromkk
0
970
note iOSチームの自動化 ver.2021/automation_with_iOS_team_on_note_ver2021
fromkk
0
2k
Bitrise体験会説明資料/bitrise_explore
fromkk
1
1.1k
noteのiOSアプリで実装したアクセシビリティの全て #iosdc #a /a11y_with_iOS_App_on_note
fromkk
2
3.9k
dSYMのアップロードで SPMを活用する/use_spm_with_upload_dsyms
fromkk
1
2.9k
Bitriseのリモートアクセス機能 #bitrise_meetup/remote_access_of_bitrise
fromkk
1
590
note社でのMagic Pod活用事例 #af_iosdc/magicpod_with_note
fromkk
2
11k
iOSには無いmacOS独自機能をCatalystで実装する #iosdc #d/make_macos_apps_with_catalyst
fromkk
9
2.1k
Other Decks in Technology
See All in Technology
Yahoo!広告ビジネス基盤におけるバックエンド開発
lycorptech_jp
PRO
1
250
Engineering Failure-Resilient Systems
infraplumber0
0
130
datadog-distribution-of-opentelemetry-collector-intro
tetsuya28
0
240
夢の印税生活 / Life on Royalties
tmtms
0
280
モノレポにおけるエラー管理 ~Runbook自動生成とチームメンションの最適化
biwashi
0
540
サイボウズフロントエンドの横断活動から考える AI時代にできること
mugi_uno
4
1.4k
LLM時代の検索とコンテキストエンジニアリング
shibuiwilliam
2
1.1k
20250818_KGX・One Hokkaidoコラボイベント
tohgeyukihiro
0
130
Observability for LLM Application lifecycle
ivry_presentationmaterials
1
230
Delegate authentication and a lot more to Keycloak with OpenID Connect
ahus1
0
240
Understanding Go GC #coefl_go_jp
bengo4com
0
1.1k
AIエージェントの開発に必須な「コンテキスト・エンジニアリング」とは何か──プロンプト・エンジニアリングとの違いを手がかりに考える
masayamoriofficial
0
330
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Art, The Web, and Tiny UX
lynnandtonic
302
21k
Visualization
eitanlees
146
16k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
31
2.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
Making the Leap to Tech Lead
cromwellryan
134
9.5k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
18
1.1k
Navigating Team Friction
lara
189
15k
Mobile First: as difficult as doing things right
swwweet
223
9.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
50
5.5k
Transcript
1લʹ࡞ͬͨͱಉ͡ తͷϥΠϒϥϦΛ·ͨ Swift 3Ͱ࡞ͬͯΈͨ AKIBA.swift #7 (C) fromkk. 2016 1
ࣗݾհ ২Ԭɹ࠸ Timers inc.ͷiOSΤϯδχΞ Twitter: @fromkk Github: fromkk Qiita: fromkk
(C) fromkk. 2016 2
એ Χοϓϧ͚ΞϓϦͷPairy ͱ Ո͚ࣸਅڞ༗ΞϓϦͷ Famm ΛӡӦ͍ͯ͠Δ Ͱ ΤϯδχΞΛืू ͍ͯ͠·͢ʂ ڵຯͷ͋Δํֻ͓͚ɺ͘͠
http://timers-inc.com/ ΑΓ͓͍߹ΘͤԼ͍͞ʂ (C) fromkk. 2016 3
ࠓͷձࣾʹೖࣾͨ͠ࠒʹ TMValidator ͱ͍͏ ϥΠϒϥϦΛ࡞͠·ͨ͠ https://github.com/fromkk/TMValidator (C) fromkk. 2016 4
(C) fromkk. 2016 5
͋Ε͔Β1 • Swift 3͕ϦϦʔε͞ΕOSSʹͳͬͨ • ࣗࣾͷΞϓϦ50%͙Β͍͕Swiftʹͳͬͨ • ͦΕʹڞͳͬͯʑॻ͘ίʔυSwiftʹ (C) fromkk.
2016 6
ࠓಉ͡ϥΠϒϥϦΛ࡞ΔͱͲ͏ͳΔ͔ʁ (C) fromkk. 2016 7
࡞ͬͯΈͨ (C) fromkk. 2016 8
Valy https://github.com/fromkk/Valy • TMValidator ͱಉ͘͡όϦσʔγϣ ϯ༻ͷϥΠϒϥϦ • Swift 3 •
Carthage, CocoaPodsରԠ (C) fromkk. 2016 9
ࢥ TMValidator ͱ΄΅ಉ͡ 1.όϦσʔλʔΛ࡞ 2.ϧʔϧΛՃ 3.จࣈྻΛνΣοΫϝιουʹͤνΣοΫ݁ՌΛฦͯ͘͠Ε Δ (C) fromkk. 2016
10
Կނ࡞͔ͬͨ • աڈʹ࡞ͬͨͷ͕࣌ؒܦͭͱૈ͕ݟ͑Δ • ࣌Πέ͍ͯͨͱࢥ͍ͬͯͨઃܭվΊͯݟΔͱ͖ͬ͢Γ͠ ͍ͯͳ͍Օॴ͕ʹͭ͘ • SwiftΒ͍͠ॻ͖ํΛࢼͯ͠Έ͔ͨͬͨ (C) fromkk.
2016 11
TMValidatorͷαϯϓϧίʔυ UITextField *name = [[UITextField alloc] init]; name.text = @"໊લ";
TMValidatorField *fieldName = [TMValidatorField fieldWithValue:name.text andLabel:@"name" andElement:name]; [[fieldName addRule:[TMValidatorRuleRequired rule]] addRule:[TMValidatorRuleMaxLength ruleWithLength:@10]]; TMValidator *validator = [TMValidator validator]; [[validator addField:fieldName]; [validator runWithSuccesses:^(NSArray *successes) { NSLog(@"success! %@", successes); } andFailure:^(NSArray *errors) { NSLog(@"failure! %@", errors); }]; (C) fromkk. 2016 12
͍ (C) fromkk. 2016 13
Valyͷαϯϓϧίʔυ let value: String? = self.textField.text let result = Valy.factory()
.add(rule: ValyRule.required) .add(rule: ValyRule.maxLength(10)) .run(with: value) switch result { case .success: print("success!") case .failure(let rule): print("failed rule \(rule)") } (C) fromkk. 2016 14
ͳΜͱͳ͖ͬ͘͢Γʁ (C) fromkk. 2016 15
TMValidatorͷ • Objective-CͩͬͨͷͰશ͕ͯclassͷҝಠࣗϧʔϧ͕࡞Γਏ ͍ • ΤϥʔίʔυɾΤϥʔϝοηʔδΛ֤ϧʔϧʹ࣋ͨͤͯ͠·ͬ ͨͷͰࣗ༝͕ޮ͔ͳ͍ • ϧʔϧΛՃ͠ͳͯ͘νΣοΫϝιουΛ࣮ߦग़དྷͯ͠·͏ (C)
fromkk. 2016 16
ValyͰͷվળ • ϧʔϧAnyValidatorRuleϓϩτίϧΛద߹͍ͤͯ͑͞͞Ε ͍͍ • ΤϥʔϋϯυϦϯάόϦσʔτ݁Ռ͔Β࣮͢ΔͷͰࣗ ༝͕ߴ͍ʢͦͷίʔυྔ૿͑Δ͔ʣ • ܕফڈʹΑΓϧʔϧΛՃ͠ͳ͍ͱόϦσʔτ͕࣮ߦग़དྷͳ͍ (C)
fromkk. 2016 17
ܕফڈ (C) fromkk. 2016 18
ܕফڈ • ෳͷϓϩτίϧʹద߹ͨ͠ཁૉΛ࡞ • ݅ʹΑ֤ͬͯϓϩτίϧͷܕΛฦ͢ (C) fromkk. 2016 19
ValyͰͷܕফڈͷྫ protocol AnyValidator { var rules: [AnyValidatorRule] { get }
static func factory() -> AnyValidator static func factory(rules: [AnyValidatorRule]) -> AnyValidatable func add(rule: AnyValidatorRule) -> AnyValidatable func add(rules: [AnyValidatorRule]) -> AnyValidatable } protocol AnyValidatable: AnyValidator { func run(with value: String?) -> ValidatorResult } Valy.factory().run(with: value) //NG! Value of type 'AnyValidator' has no member 'run' Valy.factory().add(rule: ValyRule.required).run(with: value) //OK! (C) fromkk. 2016 20
·ͱΊ • ࣌ͷྲྀΕʹܦݧʹΑͬͯઃܭͷ෯͕૿͑ͨʢؾ͕͢Δʣ • ܕফڈΛར༻͢ΕίʔυΛॻ͘ଆʹ੍ݶΛՃ͑Δࣄ͕ग़དྷ ͯόάΛੜΈਏ͍ (C) fromkk. 2016 21
͍ͬͯ͏༰Ͱ Swift Advent Calendar 2016ʹ هࣄΛॻ͘ͷͰ ετοΫ ͍͍Ͷ Լ͍͞ʂ (C)
fromkk. 2016 22
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝ ·ͨ͠ʂ (C) fromkk. 2016 23