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
Code reviewing in iOS app development
Search
yashigani
May 20, 2015
Programming
9
4.4k
Code reviewing in iOS app development
Code reviewing in iOS app development
@Kansai Mobile Conference #2
yashigani
May 20, 2015
Tweet
Share
More Decks by yashigani
See All by yashigani
Hatena Engineer Seminar #10
yashigani
0
2.2k
Dependency Injection in iOS Apps
yashigani
2
460
Multiple layout with UITableViewCell
yashigani
1
3.4k
Lazy stored property
yashigani
3
2.1k
Useful 3 techniques developing in iOS Apps
yashigani
0
1.5k
Introduction to WebKitPlus
yashigani
2
2.3k
Types in Swift
yashigani
5
2.3k
Swift with apps by Hatena
yashigani
13
29k
What's new WebKit.framework
yashigani
2
1.4k
Other Decks in Programming
See All in Programming
のびしろを広げる巻き込まれ力:偶然を活かすキャリアの作り方/oso2024
takahashiikki
1
410
2万ページのSSG運用における工夫と注意点 / Vue Fes Japan 2024
chinen
3
1.3k
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.1k
gopls を改造したら開発生産性が高まった
satorunooshie
8
240
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
330
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
430
現場で役立つモデリング 超入門
masuda220
PRO
13
2.9k
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
910
プロジェクト新規参入者のリードタイム短縮の観点から見る、品質の高いコードとアーキテクチャを保つメリット
d_endo
1
1k
Vue.js学習の振り返り
hiro_xre
2
130
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
150
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
480
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
88
5.7k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
328
21k
GraphQLの誤解/rethinking-graphql
sonatard
66
9.9k
Code Review Best Practice
trishagee
64
17k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Practical Orchestrator
shlominoach
186
10k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Intergalactic Javascript Robots from Outer Space
tanoku
268
27k
Git: the NoSQL Database
bkeepers
PRO
425
64k
Art, The Web, and Tiny UX
lynnandtonic
296
20k
Product Roadmaps are Hard
iamctodd
PRO
48
10k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Transcript
J04ΞϓϦͷίʔυϨϏϡʔ Ͱ࠷ۙؾʹͳΔͱ͜Ζ @yashigani ؔϞόΠϧΞϓϦݚڀձ#2
yashigani id:yashigani_w @yashigani Mobile Application Engineer http://yashigani.hatenablog.com Hatena
https://flic.kr/p/b3j2n2 ίʔυϨϏϡʔ ͯ͠·͔͢ʁ
ͳΜ͔ωλ୳ͯͨ͠ΜͰ͚͢Ͳಛʹ͜Εͬ ͯͷ͕ແͯ͘ɼ͋ΕʁίʔυϨϏϡʔͱ ͔ΊͬͪΌҙࣝߴͦ͏Ͱ͍͍Μ͡ΌͶʁͬ ͓ͯͬͯ·ͱΊͯΈͨΜͰ͢Αɽͦͨ͠ ΒίʔυϨϏϡʔͷ؍ͬͯΑ͘ߟ͑ͨΒ ΞϓϦέʔγϣϯΛઃܭ͢Δͱ͖ʹؾΛ ͚ͭΔ͖ϙΠϯτ·ͱΊΈ͍ͨͳײ͡ ͳΜͰ͢ΑɽͳΜͰͦ͏͍͏͜ͱ͢ΜͰ ͚͢ͲɼίʔυϨϏϡʔ͓͍ͬͯͯͨ͠ ΄͏͕ͳΜ͔͋Γ͕ͨΈ͕ߴ͍ΜͰࠓ
ίʔυϨϏϡʔͷͱ͍͏͜ͱʹͳΓ·͢ɽ
TUPSZCPBSEؔ࿈
͜ΕstoryboardͰͰ͖·ͤΜ͔ʁ • ࡉ͔͍viewͷઃఆͰ͖Δ͚ͩstoryboardͰ݁͞ ͤͨ΄͏ָ͕ • ࢄ͢Δͱ͋ͱͰ͠ʹ͍͘ • ϨΠΞτͷίʔυجຊॻ͔ͳ͍ • (AutoLayoutͷϨϏϡʔࠜੑͰΔ)
storyboardͰઃఆͰ͖ͳ͍ • viewDidLoadͱ͔awakeFromNibͰೖΕΔͷ! • propertyͷdidSetΛͬͨ΄͏͕៉ྷ • Objective-C?ૣ͘غͯͯ͘Ε
class ViewController: UIViewController { @IBOutlet weak var textView: UITextView! {
didSet { textView.textContainerInset = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16) } } }
IBInspectableΛઃఆ͢Δ • ઃఆ͠ͳ͍ཧ༝ͳ͍ • ΠϚΠν͍ʹ͔ͬͨ͘ΧελϜϏϡʔͷ࠶ར༻ੑ ͕ΊͬͪΌ্͕Γ·͢
@IBDesignable class BorderedLabel: UILabel { @IBInspectable var borderColor: UIColor? {
get { return UIColor(CGColor: self.layer.borderColor) } set { self.layer.borderColor = newValue?.CGColor ?? nil } } @IBInspectable var borderWidth: CGFloat = 1.0 { didSet { layer.borderWidth = borderWidth } } @IBInspectable var cornerRadius: CGFloat = 0.0 { didSet { layer.cornerRadius = cornerRadius layer.masksToBounds = cornerRadius > 0.0 } } }
@IBDesignable class BorderedLabel: UILabel { @IBInspectable var borderColor: UIColor? {
get { return UIColor(CGColor: self.layer.borderColor) } set { self.layer.borderColor = newValue?.CGColor ?? nil } } @IBInspectable var borderWidth: CGFloat = 1.0 { didSet { layer.borderWidth = borderWidth } } @IBInspectable var cornerRadius: CGFloat = 0.0 { didSet { layer.cornerRadius = cornerRadius layer.masksToBounds = cornerRadius > 0.0 } } }
7JFX$POUSPMMFSؔ࿈
͜ͷpropertyݮΒͤ·ͤΜ͔ʁ • stored propertyঢ়ଶͳͷͰͰ͖Δ͚ͩݮΒͨ͠΄ ͏͕Α͍ • computed propertyผ • closureͰΩϟϓνϟ͢Δͱ͔ͰͳΜͱ͔Ͱ͖ͳ͍͔
UITableViewDataSource ׂͰ͖·ͤΜ͔ʁ • UITableViewDataSourceׂ͍͢͠ͷͰૣΊʹ ׂ͓ͯ͘͠ • NSObjectstoryboard͔ΒೖͰ͖Δ
UITableViewDataSource ׂͰ͖·ͤΜ͔ʁ • UITableViewDataSourceׂ͍͢͠ͷͰૣΊʹ ׂ͓ͯ͘͠ • NSObjectstoryboard͔ΒೖͰ͖Δ
?ΑΓ! • viewDidLoadprepareForSegueͰॳظԽ͢ΔΑ͏ ͳpropertyOptionalʹ͕ͪ͠ • OptionalΑΓImplicitly Unwrapped Optionalͷ΄͏ ͕͍͍͢ •
Ͳ͏ͤແ͍ͱಈ͔ͳ͍Μ͔ͩΒૣ͘Ϋϥογϡͨ͠ ΄͏͕ಘ
4XJGUؔ࿈
computed property͑·ͤΜ͔ʁ • ఆͦͷΦϒδΣΫτͷঢ়ଶ͔Βࢉग़Ͱ͖ΔΛ ฦ͢ϝιουcomputed propertyʹ • υϝΠϯΛด͡ࠐΊΒΕΔ • ͋ͱ()͕͍Βͳ͘ͳΔͷͰྑ͍
enum͑·ͤΜ͔ʁ • ϓϦϛςΟϒͳઐ༻ͷΦϒδΣΫτͰঢ়ଶΛ ཧ͍͍ͯ͠ͷখֶੜ·Ͱ • UITableViewͷsectionͱ͔(Raw ValuesΛ͏ͱΑ͍) • enumʹด͡ࠐΊΔ •
ྫ͑section headerͷλΠτϧͱ͔ • Associated Valuesߟྀ͢Δ
lazyͰOptionalΛ֎͢ • ࣗͷproperty Aʹґଘ͢Δproperty Bͷ • B͕ඞཁͳͱ͖ʹAଘࡏ͢Δͱ͖ɼBΛlazyʹ͢ Δ͜ͱͰOptionalΛ֎͢͜ͱ͕Ͱ͖Δ
class BookmarkManager { let manager: UserManager init(_ manager: UserManager) {
self.manager = manager } } class ViewController: UIViewController { var userManager: UserManager! var bookmarkManager: BookmarkManager! override func viewDidLoad() { bookmarkManager = BookmarkManager(userManager) } }
class BookmarkManager { let manager: UserManager init(_ manager: UserManager) {
self.manager = manager } } class ViewController: UIViewController { var userManager: UserManager! lazy var bookmarkManager: BookmarkManager = BookmarkManager(self.userManager) }
ςετͰ!ΛΘͳ͍ • ςετ͕ࣦഊ͢ΔΜ͡Όͳͯ͘མͪΔ • CIͰٽ͘ • ࠷ѱͷঢ়ଶ • ͕औಘͰ͖ΔͣͰOptional Chainͱ͔҆શͳ
खஈΛ͏
let bookmark: Bookmark = ... XCTAssertNotNil(bookmark.title, "...") XCTAssertEqual(bookmark.title!, "ؔ ϞόΠϧΞϓϦݚڀձ#2",
"...")
let bookmark: Bookmark = ... XCTAssertNotNil(bookmark.title, "...") XCTAssertEqual(bookmark.title ?? "",
"ؔϞόΠϧΞϓϦݚڀձ#2", "...")
·ͱΊ
• storyboard͍ͯ͠΄͍͠ • View Controllerͱʹ͔͘ଠΒͳ͍Α͏ʹ͢Δ • Swiftͱʹ͔͘࠷ߴ
͋Γ͕ͱ͏͍͟͝·ͨ͠