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.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
AI時代のUIはどこへ行く?その2!
yusukebe
22
7.5k
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
7.7k
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
610
技術記事、 専門家としてのプログラマ、 言語化
mizchi
13
6.5k
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
120
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
120
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
14
5.8k
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
920
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
140
1B+ /day規模のログを管理する技術
broadleaf
0
110
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.4k
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.4k
Featured
See All Featured
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
Navigating Team Friction
lara
192
16k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.4k
Accessibility Awareness
sabderemane
1
140
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
330
AI: The stuff that nobody shows you
jnunemaker
PRO
8
730
Leo the Paperboy
mayatellez
7
1.9k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
240
Marketing to machines
jonoalderson
1
5.5k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
200
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
210
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࠷ߴ͗͢Δ
͋Γ͕ͱ͏͍͟͝·ͨ͠