Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
MVC-N Discussion
Search
Marcus S. Zarra
March 10, 2016
Technology
47k
8
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
MVC-N Discussion
A discussion about proper networking in your iOS based application
Marcus S. Zarra
March 10, 2016
Other Decks in Technology
See All in Technology
JSONataとAWS Step Functionsで目指すRuntimelessな世界
mu7889yoon
0
440
GoのInterface内部構造から学ぶ!最高パフォーマンスを出すコード設計
yappli_developers
1
250
ほんとうの信頼性はヒーローが死んでからはじまる / True reliability begins after the hero dies
vtryo
0
100
AIエージェントの一手は 誰も見ていない - Falco拡張OSS「Prempti」とeBPFで サーバーレス実行基盤を二層防御する
keitah
0
490
Minecraft JavaのMODをSwiftで作る
1mash0
0
200
The Knowledge Spine: A Machine-Executable Ontology for Governed Marketing Activation
vananth22
0
120
研究開発部の紹介 / Sansan R&D Profile
sansan33
PRO
5
25k
データ_AIの事業の勝敗をわけるもの
nek0128
1
470
顧客に向き合う開発組織へ。リアーキテクチャとフィーチャーチーム化で挑む組織改革
safie
0
2.4k
AIに任せた品質は、誰が見立てるのか - AI時代のテストマネジメント
nakanao
3
2.8k
人間はどの意思決定を手放せるのか
kawasima
15
8k
Kiro Meetup #8 Kiro アップデート (2026/3/21〜2026/9/24)
katzueno
1
140
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
730
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
370
Being A Developer After 40
akosma
91
590k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
340
The World Runs on Bad Software
bkeepers
PRO
72
12k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Everyday Curiosity
cassininazir
0
320
The SEO identity crisis: Don't let AI make you average
varn
0
560
GraphQLとの向き合い方2022年版
quramy
50
15k
Transcript
Marcus S. Zarra MVC-N
MyUIViewController Network Request Network Request OtherUIViewController Network Request Network Request
ThirdUIViewController Network Request Network Request Controller Layer FourthUIViewController Network Request Network Request Core Data Anti-Pattern
MVCN Network Controller
MVCN MyUIViewController OtherUIViewController ThirdUIViewController FourthUIViewController NetworkController NR NR NR NR
NR NR Core Data The Net
NetworkController NR NR NR NR NR NR Network Controller Dependency
Injection Singleton AppDelegate property class NetworkController: NSObject { } let queue = NSOperationQueue() var mainContext: NSManagedObjectContext? func requestMyData() func requestMyData() -> NSFetchedResultsController func requestMyData(completion: (Void) -> Bool)
NetworkController NR NR NR NR NR NR Network Controller class
MyNetworkRequest: NSOperation { var context: NSManagedObjectContext? init(myParam1: String, myParam2: String) }
class MyNetworkRequest: NSOperation { var context: NSManagedObjectContext? private var innerContext:
NSManagedObjectContext? private var task: NSURLSessionTask? private let incomingData = NSMutableData() init(myParam1: String, myParam2: String) { super.init() //set some parameters here } var internalFinished: Bool = false override var finished: Bool { get { return internalFinished } set (newAnswer) { willChangeValueForKey("isFinished") internalFinished = newAnswer didChangeValueForKey("isFinished") } } }
func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveResponse response: NSURLResponse, completionHandler: (NSURLSessionResponseDisposition)
-> Void) { if cancelled { finished = true sessionTask?.cancel() return } //Check the response code and react appropriately completionHandler(.Allow) } func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveData data: NSData) { if cancelled { finished = true sessionTask?.cancel() return } incomingData.appendData(data) }
func URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError error: NSError?) { if
cancelled { finished = true sessionTask?.cancel() return } if error != nil { self.error = error log("Failed to receive response: \(error)") finished = true return } //PROCESS DATA INTO CORE DATA finished = true }
Unit Testing
Network Conditions • Operations can report speeds • Control Performance
via the Queue • Network Controller can react to conditions • Central location for canceling of actions • Single decision point for background processing
Wrap up • Own your network code • Don’t put
network code in view controllers • Keep all network code together • All UI should feed from Core Data • Disconnect data collection and data display
Marcus S. Zarra
[email protected]
http://www.cimgf.com Thank You