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.3k
継続渡しと契約による設計 / 20190319 #tryswift_pre
takasek
8
2k
Continuation-Passing Style and Design By Contract(English ver.) / 20190319(E) #tryswift_pre
takasek
1
280
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
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
270
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
740
선언형 UI에서의 상태관리
l2hyunwoo
0
160
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
From Translations to Multi Dimension Entities
alexanderschranz
2
130
Recoilを剥がしている話
kirik
5
6.7k
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
130
たのしいparse.y
ydah
3
120
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
110
ドメインイベント増えすぎ問題
h0r15h0
2
300
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
The Cult of Friendly URLs
andyhume
78
6.1k
Making Projects Easy
brettharned
116
5.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
The Invisible Side of Design
smashingmag
298
50k
It's Worth the Effort
3n
183
28k
Done Done
chrislema
181
16k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
Side Projects
sachag
452
42k
Code Review Best Practice
trishagee
65
17k
Making the Leap to Tech Lead
cromwellryan
133
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