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.8k
大で小を兼ねるな
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.4k
Clean Architecture: クライアントアプリの「中心」とは何か / 20200121 the center of the client #ios_ca
takasek
10
3.5k
SOLID原則を生活に適用する / 20190906 iOSDC
takasek
4
12k
APIレスポンスにおける直和型の表現を考える / 20190730 sekkeikaigi
takasek
4
1.4k
Dark Mode / 20190617 #wwdc_rusuban
takasek
11
1.4k
継続渡しと契約による設計 / 20190319 #tryswift_pre
takasek
8
2k
Continuation-Passing Style and Design By Contract(English ver.) / 20190319(E) #tryswift_pre
takasek
1
290
FiNCのクライアントアーキテクチャを揃える試み / 20190110 #app_mp
takasek
1
6.9k
SOLID原則のSとDとテストの話 - 「Swiftらしく設計する」Another / 20181221 #roppongiswift
takasek
1
1.2k
Other Decks in Programming
See All in Programming
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
770
ESLintプラグインを使用してCDKのセオリーを適用する
yamanashi_ren01
2
240
ecspresso, ecschedule, lambroll を PipeCDプラグインとして動かしてみた (プロトタイプ) / Running ecspresso, ecschedule, and lambroll as PipeCD Plugins (prototype)
tkikuc
2
1.9k
AWS re:Invent 2024個人的まとめ
satoshi256kbyte
0
100
ゼロからの、レトロゲームエンジンの作り方
tokujiros
3
1.1k
Simple組み合わせ村から大都会Railsにやってきた俺は / Coming to Rails from the Simple
moznion
3
2.1k
rails newと同時に型を書く
aki19035vc
5
710
ChatGPT とつくる PHP で OS 実装
memory1994
PRO
3
190
PHPカンファレンス 2024|共創を加速するための若手の技術挑戦
weddingpark
0
140
.NETでOBS Studio操作してみたけど…… / Operating OBS Studio by .NET
skasweb
0
120
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
1k
盆栽転じて家具となる / Bonsai and Furnitures
aereal
0
1.9k
Featured
See All Featured
Gamification - CAS2011
davidbonilla
80
5.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.7k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Documentation Writing (for coders)
carmenintech
67
4.5k
Visualization
eitanlees
146
15k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
We Have a Design System, Now What?
morganepeng
51
7.3k
Facilitating Awesome Meetings
lara
51
6.2k
Code Review Best Practice
trishagee
65
17k
It's Worth the Effort
3n
183
28k
Raft: Consensus for Rubyists
vanstee
137
6.7k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.4k
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