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
大で小を兼ねるな
Search
takasek
September 28, 2016
Programming
4
1.7k
大で小を兼ねるな
potatotips #33 (iOS/Android開発Tips共有会)
http://potatotips.connpass.com/event/38557/
の発表資料です。
takasek
September 28, 2016
Tweet
Share
More Decks by takasek
See All by takasek
影響スケッチでFatViewControllerを可視化してみよう' / 20200530 effect sketch #swiftzoomin
takasek
1
1.2k
Clean Architecture: クライアントアプリの「中心」とは何か / 20200121 the center of the client #ios_ca
takasek
10
3.4k
SOLID原則を生活に適用する / 20190906 iOSDC
takasek
4
12k
APIレスポンスにおける直和型の表現を考える / 20190730 sekkeikaigi
takasek
4
1.3k
Dark Mode / 20190617 #wwdc_rusuban
takasek
11
1.3k
継続渡しと契約による設計 / 20190319 #tryswift_pre
takasek
8
1.9k
Continuation-Passing Style and Design By Contract(English ver.) / 20190319(E) #tryswift_pre
takasek
1
260
FiNCのクライアントアーキテクチャを揃える試み / 20190110 #app_mp
takasek
1
6.7k
SOLID原則のSとDとテストの話 - 「Swiftらしく設計する」Another / 20181221 #roppongiswift
takasek
1
1.2k
Other Decks in Programming
See All in Programming
TiDB Serverless ~理想のServerless DBを考える~
soso_15315
1
160
I/O Extended Android in Korea 2024 ~ Whats new in Android development tools
pluu
0
250
初心者がおさえておきたいAWS CDKのベストプラクティス 2024
konokenj
15
7.3k
ドメイン駆動設計の実践
masuda220
PRO
20
5.3k
Webエディタライブラリ 「CodeMirror」から学ぶ Webアプリ開発のテクニック
ryosukeigarashi
0
250
Namespace on read
tagomoris
2
370
しくじり先生 Image Matching Challenge 2024 編
goosehaaan
0
810
CSC307 Lecture 14
javiergs
PRO
0
220
APIのない大学ログインWebサービスをWKWebViewとJavaScriptでアプリ化した話
akidon0000
1
330
ピグパーティにおけるMongoDB CommunityバージョンからAtlasへの移行事例
10969hotaka
0
130
OpenAI/Gemini APIを使って EPUBを翻訳するCLIツールをつくってみた
tomiyan
0
800
AWS CDKにおける「再利用性」を考える / aws-cdk-reusability
gotok365
6
1.3k
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
35
4.4k
Design by the Numbers
sachag
277
19k
What's in a price? How to price your products and services
michaelherold
239
11k
Typedesign – Prime Four
hannesfritz
37
2.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
353
29k
Mobile First: as difficult as doing things right
swwweet
219
8.8k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
189
16k
Bash Introduction
62gerente
607
210k
How To Stay Up To Date on Web Technology
chriscoyier
784
250k
Navigating Team Friction
lara
181
13k
Designing for Performance
lara
604
67k
What’s in a name? Adding method to the madness
productmarketing
PRO
21
2.9k
Transcript
େͰখΛ݉ͶΔͳ by takasek 2016/9/28 potatotips 33 1
2
3
օ͞Μ Λཧ͢Δͱ͖ɺ ͲͷܕΛ͍·͔͢ʁ 4
NSDate? 5
ͱ͍ Date? 6
͋ͳͨͷΞϓϦͷ ༷ 4 Ұ24࣌ؒ 7
͋ͳͨͷΞϓϦͷ ༷ 4 Ұ24࣌ؒ 4 ͕มΘΔͷɺே8࣌ 8
͋ͳͨͷΞϓϦͷ ༷ 4 Ұ24࣌ؒ 4 ͕มΘΔͷɺே8࣌ ɹ ※͜ͷΛɺ ɹ௨ৗͷͱ۠ผ͢ΔͨΊʹɺ ɹShachikuDate
ͱݺͼ·͢ 9
ShachikuDateͷจࣈྻදݱΛಘΔ func shachikuDateDescription (_ !: Date) -> String { let
formatter = DateFormatter() formatter.dateFormat = "yyyyMM݄dd" return formatter.string(from: !) } 10
ShachikuDateΛ͍͍ͨ let ! = parseDate("2016-09-28 07:59:58") //"8࣌લͳͷͰɺ shachikuDateDescription(!) //201609݄27 #ͱද͍ࣔͨ͠
11
͜Μͳ;͏ʹม͢Δʁ extension Date { var shachikuDate: Date { if self.hour
< 8 { //8࣌લͳΒ return (self.day - 1) //ࡢʹ͢Δ } else { return self } } } ※ͪΐͬͱٖࣅίʔυ 12
ᶃ let !1 = parseDate("2016-09-27 08:00:00") let !2 = parseDate("2016-09-28
07:59:58") !1.shachikuDate < !2.shachikuDate વtrueΛظ͠·͢ΑͶʁɹͰ… 13
ᶃ let !1 = parseDate("2016-09-27 08:00:00") let !2 = parseDate("2016-09-28
07:59:58") !1.shachikuDate < !2.shachikuDate // false" 14
ᶃ ͳͥͳΒ let !1 = parseDate("2016-09-27 08:00:00") let !2 =
parseDate("2016-09-28 07:59:58") !1.shachikuDate // "2016-09-27 08:00:00" "มԽͯ͠ͳ͍ !2.shachikuDate // "2016-09-27 07:59:58" "ҰḪͬͯΔ 15
ᶄ func printHoge(with !: Date) { printFuga(!.shachikuDate) } func printFuga(with
!: Date) { print(!.shachikuDate) } let ! = parseDate("2016-09-28 07:59:58") printHoge(with: !) // "201609݄26" ࡢ(9/27)ͷΛظ͍ͯ͠Δͷʹɺ Ұࡢ(9/26)ʹͳ͍ͬͯΔ… 16
ᶄ func printHoge(with !: Date) { printFuga(!.shachikuDate) } func printFuga(with
!: Date) { print(!.shachikuDate) } ɹ Α͘ಡΉͱɺ 1. printHoge(with:) ͰલͷDateʹม 2. printHoge(with:) ͔Β printFuga(with:) ΛݺͿ 4 printFuga(with:) ͰߋʹલͷDateʹม 17
!"#$%!"$% όάʹؾ͚Δ ؾ͕͠ͳ͍… %$"!%$#"! 18
ᶅ ϢʔβʔೖྗΛɺαʔόʹૹΔ func didReceiveUserInput (year: Int, month: Int, day: Int)
{ let ! = Date( calendar: Caldendar.default, year: year, month: month, day: day ) API.send(!) } 19
!ʮͳ͋ʯ 20
!ʮDBʹ 4004ͱ͔ ೖͬͯΔΜ͚ͩͲʯ 21
!? 22
func didReceiveUserInput (year: Int, month: Int, day: Int) { let
! = Date( calendar: Caldendar.default, year: year, month: month, day: day ) API.send(!) } ɹ ! Ͳ͜ʹ͕…!? 23
func didReceiveUserInput (year: Int, month: Int, day: Int) { let
! = Date( calendar: Caldendar.default, //"࣮ྐྵઃఆ#ͯͨ͠!!! year: year, //$2016 month: month, day: day ) API.send(!) } ྐྵઃఆͳͷͰ ! = ฏ2016 = 1988 + 2016 = ྐྵ4004 ͱ͍͏Φν 24
ॾѱͷࠜݯ Dateͱ͍͏ܕΛ ͍ճ͍ͯ͠Δ 25
Dateܕศར 26
λΠϜκʔϯͷҧ͍ ྐྵ๏ͷҧ͍ શ෦ٵऩͯ͘͠ΕΔ 27
Ͱ ࣌ࠁͷࡉ੍͔͍ޚͬͯ ࠓɺඞཁʁ 28
ࠓɺྐྵ๏ͬͯඞཁʁ 29
ShachikuDate͕΄͍͠ͷ ! ͚ͩ 30
ͳΒɺ struct YMD { let year: Int let month: Int
let day: Int var description: String { return "\(year)\(month)݄\(day)" } } let ! = YMD(year: 2016, month: 9, day: 28) 31
γϯ ϓϧ 32
όάͷೖΓࠐΈΑ͏͕ͳ͍ 33
!✨ 34
ಉ͜͡ͱ ΤϯδχΞϦϯάͷ ༷ʑͳঢ়گͰ ݴ͑ͯɺ 35
ྫ1 ☑ จষΛද͍ࣔͨ͠ ☑ Ұఆͷߴ͞Λ͑ͨΒεΫϩʔϧ͍ͤͨ͞ ! ͩͬͨΒUITextViewͰ͠ΐ͏ 36
݁Ռ1 ! จষྖҬͷϚʔδϯͷ੍ޚͭΒ͍… จষྖҬͷheight͕͏·͘औΕͳ͍… …ਏ͍… 37
!NSLayoutManager !NSTextStorage !NSTextContainer !etc... 38
UITextViewͷ ෦ߏ ҙ֎ͱຐڥ 39
εΫϩʔϧͰ͖ΔLabel͕ ཉ͍͚ͩ͠ͳΒɺ UITextView ΦʔόʔεϖοΫ 40
݁ہ1 ! UILabel Λ UIScrollView ʹೖΕΔ࣮Ͱ ͘͢͝γϯϓϧʹղܾͰ͖ͨ… ʢίʔυ1ߦॻ͔ͣɺ ɹInterfaceBuilderͰ݁Ͱ͖ΔϨϕϧʣ 41
ྫ2 ! ◦◦ػೳΛ͍͍ͨͷͰ ͋ͷϥΠϒϥϦೖΕΑ͏ͬͱʂ 42
݁Ռ2 ! ͋ͷϥΠϒϥϦͷ××ػೳʢผʹཁΒͳ͍ʣ ͕ ґଘ͢ΔผͷϥΠϒϥϦͷ͍ͤͰ Xcode8ରԠ͕ਐ·ͳ͍… ! ͰϥΠϒϥϦ ࠓߋແཧ… 43
͓Θ͔ΓͩΖ͏͔ ػೳ͕ଟ͍ ʹ ᠘͕ଟ͍ 44
େ͕খΛ݉ͶΔͱ ൵͠Έ͕ੜ·ΕΔ 45
ͱ͍͏Θ͚Ͱ 46
େࣄͳ͜ͱͳͷͰ ͏Ұݴ͍·͢ 47
େͰ খΛ ݉ͶΔͳ 48
ɹҎ্ɻ 49
see also: UNIXֶ - Wikipedia 50