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.8k
SOLID原則のSとDとテストの話 - 「Swiftらしく設計する」Another / 20181221 #roppongiswift
takasek
1
1.2k
Other Decks in Programming
See All in Programming
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
920
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.1k
Click-free releases & the making of a CLI app
oheyadam
2
120
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
1.9k
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
600
Macとオーディオ再生 2024/11/02
yusukeito
0
370
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.1k
最新TCAキャッチアップ
0si43
0
140
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
340
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
40
2.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
96
How to Ace a Technical Interview
jacobian
276
23k
Ruby is Unlike a Banana
tanoku
97
11k
Faster Mobile Websites
deanohume
305
30k
Scaling GitHub
holman
458
140k
Music & Morning Musume
bryan
46
6.2k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
A better future with KSS
kneath
238
17k
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