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
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
13k
Strategic Design in the Frontend: Moduliths & Micro Frontends @DDDEurope
manfredsteyer
PRO
0
130
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
230
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
170
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
300
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
120
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.2k
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
1
110
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
130
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
580
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
2
680
Featured
See All Featured
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
400
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Leo the Paperboy
mayatellez
7
1.9k
Designing for humans not robots
tammielis
254
26k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
540
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Paper Plane (Part 1)
katiecoart
PRO
0
9.2k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Embracing the Ebb and Flow
colly
88
5.1k
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࠷ߴ͗͢Δ
͋Γ͕ͱ͏͍͟͝·ͨ͠