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
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.5k
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
The Bowling Game- From Imperative to Functional Programming - Part 1
philipschwarz
PRO
0
330
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
520
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
130
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
2.7k
分散システム、なんですぐ死んでしまうん?耐障害性を高めたいあなたのためのレジリエンスパターン入門
mshibuya
7
6.2k
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
850
20260623_Loop Engineeringで自分の分身の問い合わせBotを作る
ryugen04
0
220
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
230
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
2
270
act2-costs.pdf
sumedhbala
0
110
ランチタイムLT会3周年!ランチタイムLT会を3年間続けられたお話
y0hgi
1
140
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
2.6k
Featured
See All Featured
How to build a perfect <img>
jonoalderson
1
5.8k
Mind Mapping
helmedeiros
PRO
1
280
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
190
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
360
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Scaling GitHub
holman
464
140k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.4k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
220
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
470
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
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࠷ߴ͗͢Δ
͋Γ͕ͱ͏͍͟͝·ͨ͠