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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Agentic UI
manfredsteyer
PRO
0
190
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
14
5.8k
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
190
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.4k
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
150
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
12
5.9k
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
390
Strategic Design in the Frontend: Moduliths & Micro Frontends @DDDEurope
manfredsteyer
PRO
0
130
Inside Stream API
skrb
1
770
New "Type" system on PicoRuby
pocke
1
1k
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
200
Oxcを導入して開発体験が向上した話
yug1224
4
340
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Designing Experiences People Love
moore
143
24k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
First, design no harm
axbom
PRO
2
1.2k
Visualization
eitanlees
152
17k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
170
WCS-LA-2024
lcolladotor
0
650
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Fireside Chat
paigeccino
42
4k
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࠷ߴ͗͢Δ
͋Γ͕ͱ͏͍͟͝·ͨ͠