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
Ways to build REST mobile client
Search
Oursky Limited
June 27, 2013
Programming
170
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ways to build REST mobile client
Oursky Limited
June 27, 2013
More Decks by Oursky Limited
See All by Oursky Limited
UI Automation
oursky
1
540
SSH Can
oursky
1
340
HTTP/2
oursky
0
380
watchOS2
oursky
0
370
Common QA issues
oursky
0
230
Complex is better than complicated
oursky
0
310
Clean code again
oursky
3
410
KiriKiri x O2 x NVLMarker
oursky
0
270
Flux + React
oursky
1
420
Other Decks in Programming
See All in Programming
AIだと陥りがちなJakarta EE最新技術への移行時の落とし穴と解決策
tnagao7
0
110
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
780
Claspは野良GASの夢をみるか
takter00
0
190
Contextとはなにか
chiroruxx
1
330
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
120
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
260
Lessons from Spec-Driven Development
simas
PRO
0
210
AI時代のUIはどこへ行く?その2!
yusukebe
21
7.2k
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
240
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
160
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.3k
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.2k
Featured
See All Featured
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
730
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
140
Everyday Curiosity
cassininazir
0
230
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
Google's AI Overviews - The New Search
badams
0
1k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
590
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
600
AI: The stuff that nobody shows you
jnunemaker
PRO
8
720
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
370
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
180
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Test your architecture with Archunit
thirion
1
2.3k
Transcript
Ways to build REST mobile client Edwin Kwok Thursday, 27
June, 13
iOS Thursday, 27 June, 13
Network Manager Network Connection Builder / Factory Network Manager Delegate
Rugby Implementation Thursday, 27 June, 13
NetworkManager NetworkConnection NewsBuilder NewsViewController<NetworkManagerDelegate> Rugby Implementation 1. ask for News
6. News 2. send request 3. response 4. parse response 5. News Thursday, 27 June, 13
WeSnap Implementation ????? Thursday, 27 June, 13
RestKit Challenges Offline Data Access Flaky Connectivity Different Data Formats
Thursday, 27 June, 13
RestKit Features Integrated HTTP Stack Pluggable Parser Object Mapping Core
Data Integration UI Integration Thursday, 27 June, 13
Integrated HTTP Stack Base URLs Custom Header Network Indicator Performing
Requests Background Processing Authentication Request caching Thursday, 27 June, 13
Integrated HTTP Stack / / create client RKClient *client =
[RKClient clientWithBaseURL:@”http:/ /github.org”]; / / set header [client setValue:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forHTTPHeaderField:@”X-UDID”]; / / set indicator behavior client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES; Thursday, 27 June, 13
Performing Request - (IBAction)forkYouWithBlocks { self.imageView.image = nil; [[RKClient sharedClient]
get:@"http:/ /github.com/fluidicon.png" usingBlock:^(RKRequest *request) { [request setBackgroundPolicy:RKRequestBackgroundPolicyContinue]; [request setOnDidLoadResponse:^(RKResponse *response) { if (response.isSuccessful) { UIImage *image = [UIImage imageWithData:response.body]; self.imageView.image = image; } }]; }]; } Thursday, 27 June, 13
Background Processing [request setBackgroundPolicy:RKRequestBackgroundPolicyContinue]; RKRequestBackgroundPolicyNone / / do nothing RKRequestBackgroundPolicyCancel
/ / cancel request RKRequestBackgroundPolicyContinue / / continue RKRequestBackgroundPolicyRequeue / / requeue upon app restart Thursday, 27 June, 13
Object Mapping Simple Object Mapping Mapping Relationships Inverse Mappings Serialization
Mappings Thursday, 27 June, 13
Object mapping { id: 1, name: “Peter”, location: “Hong Kong”,
followers: 1, email: “
[email protected]
”, following: 36 } @interface User : NSObject @property (strong, nonatomic) NSNumber *id; @property (strong, nonatomic) NSString *name; @property (strong, nonatomic) NSString *location; @property (strong, nonatomic) NSNumber *followers; @property (strong, nonatomic) NSString *email; @property (strong, nonatomic) NSNumber *following; @end Thursday, 27 June, 13
Object mapping / / register mapping for a class objectMapping
= [RKObjectMapping mappingForClass:[User class]]; [objectMapping mapKeyPath:@"id" toAttribute:@"id"]; [objectMapping mapKeyPath:@"name" toAttribute:@"name"]; [objectMapping mapKeyPath:@"location" toAttribute:@"location"]; [objectMapping mapKeyPath:@"email" toAttribute:@"email"]; [objectMapping mapKeyPath:@"following" toAttribute:@"following"]; [objectMapping mapKeyPath:@"followers" toAttribute:@"followers"]; Thursday, 27 June, 13
Object mapping [[RKObjectManager sharedManager] loadObjectsAtResourcePath:[NSString stringWithFormat:@"/users/%@", userName] usingBlock:^(RKObjectLoader *loader) {
[SVProgressHUD showWithStatus:@"Loading..."]; [loader setObjectMapping:objectMapping]; [loader setOnDidLoadObject:^(id object) { [SVProgressHUD dismiss]; }]; [loader setOnDidFailWithError:^(NSError *error) { [SVProgressHUD showErrorWithStatus:@"Problem loading user"]; }]; }]; Thursday, 27 June, 13
Mapping Relationship RKObjectMapping *userMapping = [RKObjectMapping mappingForClass:[User class]]; RKObjectMapping *issueMapping
= [RKObjectMapping mappingForClass:[Issue class]]; / / create relationships [issueMapping mapKeyPath:@"user" toRelationship:@"user" withMapping:userMapping]; { number: 1, title: “Issue #1”, user: { ... } } @interface Issue : NSObject @property (strong, nonatomic) NSNumber *number; @property (strong, nonatomic) NSString *title; @property (strong, nonatomic) User *user; @end Thursday, 27 June, 13
Android Thursday, 27 June, 13
Thursday, 27 June, 13
Problem The operating system may shut down the process Solution:
use service Thursday, 27 June, 13
Use a Service API Thursday, 27 June, 13
Use ContentProvider API Thursday, 27 June, 13
Google I/0 2013 Volley: Easy, Fast Networking for Android Thursday,
27 June, 13
Why Volley Restful apps have common features: infinite scroll image
loading offline caching request priority Volley provides all of them Thursday, 27 June, 13
Reference http:/ /www.amazon.com/Test-Driven-iOS- Development-Developers-Library/dp/ 0321774183 http:/ /restkit.org/ https:/ /dl.google.com/googleio/2010/android- developing-RESTful-android-apps.pdf
http:/ /www.youtube.com/watch? v=yhv8l9F44qo Thursday, 27 June, 13