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
Useful 3 techniques developing in iOS Apps
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
yashigani
April 18, 2015
Programming
1.6k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Useful 3 techniques developing in iOS Apps
Cocoa study Kansai #61
yashigani
April 18, 2015
More Decks by yashigani
See All by yashigani
Hatena Engineer Seminar #10
yashigani
0
2.4k
Dependency Injection in iOS Apps
yashigani
2
530
Multiple layout with UITableViewCell
yashigani
1
3.6k
Lazy stored property
yashigani
3
2.2k
Code reviewing in iOS app development
yashigani
9
4.6k
Introduction to WebKitPlus
yashigani
2
2.5k
Types in Swift
yashigani
5
2.4k
Swift with apps by Hatena
yashigani
13
30k
What's new WebKit.framework
yashigani
2
1.6k
Other Decks in Programming
See All in Programming
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
220
A2UI という光を覗いてみる
satohjohn
1
150
AIで効率化できた業務・日常
ochtum
0
140
dRuby over BLE
makicamel
2
390
トークンをケチるな、設計しろ:GitHub Copilotを賢く使うコンテキスト戦略
ochtum
0
150
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
360
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
140
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
230
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
2
680
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
140
Featured
See All Featured
Site-Speed That Sticks
csswizardry
13
1.2k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Evolving SEO for Evolving Search Engines
ryanjones
0
220
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1.1k
A designer walks into a library…
pauljervisheath
211
24k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
Optimizing for Happiness
mojombo
378
71k
Transcript
ཱ͓ͪςΫχοΫ࿈ൃ @yashigani Cocoaษڧձؔ #61
yashigani id:yashigani_w @yashigani Mobile Application Engineer http://yashigani.hatenablog.com Hatena
એ
IUUQDPOOQBTTDPNFWFOU
IUUQDPOOQBTTDPNFWFOU
IUUQDPOOQBTTDPN FWFOU
ը໘αΠζʹ߹Θͤͯ 6*4DSPMM7JFXΛ ͍͍͔Μ͡ʹ͢Δ @yashigani Cocoaษڧձؔ #61
None
None
͜Ε4ͩͱͲ͏ͳΔΜͰ͔͢ʁ ͏ʔΜɼεΫϩʔϧ͠·͢
None
None
ࠔͬͨ
ը໘αΠζຖʹϨΠΞτ • ߴղ૾ • ը໘ϐολϦʹ͛ͯηϯλϦϯά͢Δ • ղ૾ • ্ԼʹదͳϚʔδϯΛͱͬͯεΫϩʔϧ͢Δ
Ṝ͍ΑΔࠈ • UIScrollView + Auto Layout • ୭͕ϋϚΔϙΠϯτ • Mixed
Approach or Pure Auto Layout Aploach • https://developer.apple.com/library/ios/ technotes/tn2154/_index.html • ઈରstoryboard͚ͩͰղܾ͍ͨ͠
ཱ͔ͪͩΔ2ͭͷ՝ • ը໘ʹೖΓ͖Βͳ͍ͱ͖͚ͩεΫϩʔϧ͍ͨ͠ • ্Լʹ࠷ݶͷϚʔδϯΛઃ͚͍͕ͨɼ༨༟͕͋Δ ߹ແࢹͯ͠ηϯλϦϯά͍ͨ͠
DPOUFOUTJ[FTVCWJFXͷ ੍ʹΑܾͬͯ·Δ
None
ηϯλϦϯάͰ͖ͨ
িಥ੍ͨ͠Λ Ճ͢Δ
None
੍ʹ QSJPSJUZΛ͚ͭΔ
None
None
͜͏ͯ͠ ৺ʹฏԺ͕๚Εͨ
6*5BCMF7JFX%BUB4PVSDF ࣮ύλʔϯ @yashigani Cocoaษڧձؔ #61
ͳͥ͢Δͷ͔ • ϙʔλϏϦςΟ • ςετ༰қੑ • storyboardʹஔ͚Δ • view controllerΛdata
sourceʹґଘͤ͞Δ • prepareForSegueͰϓϦϛςΟϒͳσʔλΛΓͱ Γͨ͘͠ͳ͍
TVCTDSJQUΛ࣮͢Δ
class DataSource: NSObject { var models: [Model] = [] subscript(indexPath:
NSIndexPath) -> Model? { return models.isEmpty ? nil : models[indexPath.row] } } extension DataSource: UITableViewDataSource { func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { switch self[indexPath] { case .Some(let m): let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! ModelCell cell.configure(m) return cell default: abort() } } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return models.count } }
TFDUJPOΛՃ͢Δ
enum Section: Int { case SectionA = 0 case SectionB
= 1 var title: String { switch self { case .SectionA: return "SectionA" case .SectionB: return "SectionB" default: return "" } } } class DataSource: NSObject { var sectionA: [Model] = [] var sectionB: [Model] = [] }
class DataSource: NSObject { subscript(section: Int) -> [Model]? { if
let section = Section(rawValue: section) { let models: [Model] switch section { case .SectionA: models = sectionA case .SectionB: models = sectionB } return models } else { return nil } } subscript(indexPath: NSIndexPath) -> Model? { if let models = self[indexPath.section] { return models.isEmpty ? nil : models[indexPath.row] } else { return nil } } }
extension DataSource: UITableViewDataSource { func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath)
-> UITableViewCell { switch self[indexPath] { case .Some(let m): let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! ModelCell cell.configure(m) return cell default: abort() } } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self[section]?.count ?? 0 } }
ઃܭΑ͘ͳͬͨ͠ ܕ҆શʹͳͬͨ
8,8FC7JFXΛ γϡοͱ͏།Ұͷํ๏ @yashigani Cocoaษڧձؔ #61
͓ͳΈϙΠϯτ • WKUIDelegateͷ࣮ • ΞϥʔτΛॲཧ͢Δ͚ͩ • webView(_:createWebViewWithConfiguration:forNa vigationAction:windowFeatures:) -> WKWebView!
• ͏KVOॻ͖ͨ͘ͳ͍ • storyboard͔ΒՃͰ͖ͳ͍
8FC,JU1MVT IUUQTHJUIVCDPNZBTIJHBOJ8FC,JU1MVT
8,6*%FMFHBUF1MVT
• alert()ͷσϑΥϧτ࣮ • ຖಉ͡ͷΛ࣮͠ͳ͍͍ͯ͘ • target=“_blank”ͳϦϯΫϩʔυͰ͖Δ • ͪΖΜ߹ʹΑͬͯผͷWKWebViewʹ • ࠩ͠ସ͑Δ͜ͱՄೳ
lazy var UIDelegate = WKUIDelegatePlus(self) override public func viewDidLoad() {
super.viewDidLoad() webView.UIDelegate = UIDelegate }
8FC7JFX0CTFSWFS
• WKWebViewKVO compliantͳproperty͕ଟ͍ • ͔͠͠KVOͳͲॻ͖ͨ͘ͳ͍ • ؔͰobserveͰ͖ΔΑ͏ʹαϙʔτ
lazy var observer = WebViewObserver(self.webView) override public func viewDidLoad() {
super.viewDidLoad() observer.onTitleChanged = { [weak self] in self?.title = $0 } observer.onProgressChanged = { [weak self] in self?.progressbar.progress = $0 } }
;FO8FC7JFX$POUSPMMFS
• Zen = “ષ” • viewͷ࠷ԼʹWKWebViewΛࠩ͠ࠐΉ • WKWebViewૢ࡞ͷͨΊͷIBAction • goBack/goForward/reload/stopLoading
• WKUIDelegatePlus, WebViewObserverΛ࣮ • storyboard͔Β͑Δͧʂʂʂ
%FNP4JNQMF#SPXTFS
ͱʹ͔͘ ͍·͙ͬͯ͘͢Ε
ࡶஊίʔφʔ @yashigani Cocoaษڧձؔ #61
• AFNetworking͕CarthageରԠڋ൱ͬͯΔ • https://github.com/AFNetworking/ AFNetworking/pull/2552 • LlamaKit͕ResultʹऔΓࠐ·ΕΔͷͭΒ͍ • https://github.com/LlamaKit/LlamaKit •
https://github.com/antitypical/Result • Xcode 6.3࠷ߴ͗͢Δ
͋Γ͕ͱ͏͍͟͝·ͨ͠