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.5k
Clean Architecture: クライアントアプリの「中心」とは何か / 20200121 the center of the client #ios_ca
takasek
10
3.6k
SOLID原則を生活に適用する / 20190906 iOSDC
takasek
4
12k
APIレスポンスにおける直和型の表現を考える / 20190730 sekkeikaigi
takasek
4
1.5k
Dark Mode / 20190617 #wwdc_rusuban
takasek
11
1.4k
継続渡しと契約による設計 / 20190319 #tryswift_pre
takasek
8
2.1k
Continuation-Passing Style and Design By Contract(English ver.) / 20190319(E) #tryswift_pre
takasek
1
290
FiNCのクライアントアーキテクチャを揃える試み / 20190110 #app_mp
takasek
1
7k
SOLID原則のSとDとテストの話 - 「Swiftらしく設計する」Another / 20181221 #roppongiswift
takasek
1
1.3k
Other Decks in Programming
See All in Programming
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
770
CloudNativePGを布教したい
nnaka2992
0
110
Serverless Rust: Your Low-Risk Entry Point to Rust in Production (and the benefits are huge)
lmammino
1
150
たのしいSocketのしくみ / Socket Under a Microscope
coe401_
8
1.2k
Rails アプリ地図考 Flush Cut
makicamel
1
130
なぜイベント駆動が必要なのか - CQRS/ESで解く複雑系システムの課題 -
j5ik2o
14
4.6k
Introduction to kotlinx.rpc
arawn
0
760
クリーンアーキテクチャから見る依存の向きの大切さ
shimabox
5
960
Django NinjaによるAPI開発の効率化とリプレースの実践
kashewnuts
1
250
推しメソッドsource_locationのしくみを探る - はじめてRubyのコードを読んでみた
nobu09
2
200
From the Wild into the Clouds - Laravel Meetup Talk
neverything
0
130
dbt Pythonモデルで実現するSnowflake活用術
trsnium
0
260
Featured
See All Featured
Become a Pro
speakerdeck
PRO
26
5.2k
Speed Design
sergeychernyshev
27
810
For a Future-Friendly Web
brad_frost
176
9.6k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Rebuilding a faster, lazier Slack
samanthasiow
80
8.9k
Automating Front-end Workflow
addyosmani
1368
200k
Building Applications with DynamoDB
mza
93
6.2k
Bash Introduction
62gerente
611
210k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
How to train your dragon (web standard)
notwaldorf
91
5.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
30
4.6k
Music & Morning Musume
bryan
46
6.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