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
◯◯エンジニアになった理由
gessy0129
PRO
0
640
ROS 2のZenoh対応とZenohのROS 2対応
takasehideki
2
290
RemixとCloudflare Stack におけるFile Upload
ossamoon
1
130
MLOps in Mercari Group’s Trust and Safety ML Team
cjhj
1
110
学生の時に開催したPerl入学式をきっかけにエンジニアが組織に馴染むために勉強会を主催や仲間と参加して職能間の境界を越えていく
ohmori_yusuke
1
130
"noncopyable types" の使いどころについて考えてみた
andpad
0
140
コードレビューと私の過去と未来
jxmtst
0
260
WEBアプリケーションにおけるAWS Lambdaを用いた大規模な非同期処理の実践
delhi09
PRO
7
4k
pytest プラグインを開発して DRY に自動テストを書こう
inuatsu
2
260
Cloud Adoption Framework にみる組織とクラウド導入戦略
tomokusaba
2
450
Real-time message handling and notifications with API Platform and Symfony
alli83
1
100
ACES Meet におけるリリース作業改善の取り組み
fukucheee
0
130
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
Designing Experiences People Love
moore
138
23k
A better future with KSS
kneath
237
17k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2k
Done Done
chrislema
181
16k
The Mythical Team-Month
searls
218
43k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.5k
[RailsConf 2023] Rails as a piece of cake
palkan
49
4.7k
Agile that works and the tools we love
rasmusluckow
327
21k
GraphQLの誤解/rethinking-graphql
sonatard
65
9.9k
How GitHub (no longer) Works
holman
311
140k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
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ͱʹ͔͘࠷ߴ
͋Γ͕ͱ͏͍͟͝·ͨ͠