SlideShare a Scribd company logo
or the Weary
No RestKit f
Matt Galloway
Architactile
matt@architactile.com
918-808-3072

Tuesday, January 28, 14
Some
Amazingly
Cool Data
from the
“Cloud”

ul* Web
RESTF es
Servic

the “Cloud”

REST-ish and JSONy.
ul,“ of course, I mean
* By “RESTF
Tuesday, January 28, 14
rvice Calls on iOS
Web Se
Define your URL
NSString *url = @”http://somewebservice.com/objects.json”;

Make the Call
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];

ese delegate methods!!!
Then implement all of th
-

(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
(void)connectionDidFinishLoading:(NSURLConnection *)connection

and now you have to parse
the JSON in NSData
into something useful...
Tuesday, January 28, 14
n is great, but...
NSJSONSerializatio
-(void) parseJSONIntoModel:(NSData *) jsonData {
NSError *error = nil;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:jsonData
options:NSJSONReadingAllowFragments
error:&error];
if (error!=nil) {
// TODO: Insert annoying JSON error handler here.
}
if ([json isKindOfClass:[NSArray class]]) {
//TODO: Uh. I was expecting a dictionary but apparently this is an array. Writng some handling code here.
}
for(NSString *key in [json allKeys]) {
if ([key isEqualToString:@"user"]) {
NSDictionary *userDictionary = [json objectForKey:key];
NSNumber *userId = [userDictionary objectForKey:@"id"];
RKGUser *user = [[ObjectFactory sharedFactory] userForUserId:userId];
if (user==nil) {
user = [[ObjectFactory sharedFactory] newUser];
user.userId=useriD;
}

}
.
.
.

user.name = [userDictionary objectForKey:@"name"];
user.username = [userDictionary objectForKey:@"username"];
user.phone = [userDictionary objectForKey:@"phone"];
user.email = [userDictionary objectForKey:@"email"];

Tuesday, January 28, 14
nter RestKit
E
https://github.com/RestK
it

/RestKit/

ing and modeling
ework for consum
RestKit is a fram
s on iOS and OS X
Tful web resource
RES

Tuesday, January 28, 14
[[RKObjectManager sharedManager] getObjectsAtPath:@"objects.json"
parameters:nil
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
// Call is successful. Objects are all populated.
}
failure:^(RKObjectRequestOperation *operation, NSError *error) {
// Call failed.
}];

Tuesday, January 28, 14
RestKit is...
rce & available on GitHub
* Open Sou
* Built on AFNetworking
Beautifully multi-threaded
*
eamlessly with CoreData
* Integrates s
o works with plain objects
* Als
lationships, nesting, etc.
* Handles re
on mapping like an ORM
* Based
* Very configurable
, POST, PATCH, etc.
ndles all REST verbs - GET
* Ha
y actively maintained
* Ver
ase seeding, search,
ch of other stuff - datab
* A bu n
XML, etc.
Tuesday, January 28, 14
ing RestKit
Install
I <3 CocoaPods
$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile
platform :ios, '5.0'
# Or platform :osx, '10.7'
pod 'RestKit', '~> 0.20.0'
$ pod install
$ open MyProject.xcworkspace

Tuesday, January 28, 14
Using RestKit: The W
e

Tuesday, January 28, 14

b Service
Using RestKit: The Object
@interface Joke : NSObject
@property (nonatomic, strong) NSNumber *jokeId;
@property (nonatomic, strong) NSString *text;
@end
@implementation Joke
@end

Tuesday, January 28, 14
Using RestKit: The Setup
-(void) setupRestKit {
RKObjectManager *objectManager =
[RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://api.icndb.com/"]];
objectManager.requestSerializationMIMEType=RKMIMETypeJSON;
[RKObjectManager setSharedManager:objectManager];
.
.
.

eps for CoreData, authentication, etc.)
(There are a few extra st

Tuesday, January 28, 14
Using RestKit: The Mappin
g
RKObjectMapping *jokeMapping = [RKObjectMapping mappingForClass:[Joke class]];
[jokeMapping addAttributeMappingsFromDictionary:@{
@"id":
@"joke":

@"jokeId",
@"text"}];

RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor
responseDescriptorWithMapping:jokeMapping
method:RKRequestMethodGET
pathPattern:@"jokes"
keyPath:@"value"
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

[[RKObjectManager sharedManager] addResponseDescriptor:responseDescriptor];

Tuesday, January 28, 14
I <3 Singletons

a singleton, so
KObjectManager is
R
apping steps need
the setup and m
e, usually at app
only be done onc
launch.
it and forget it. :)
Se t

Tuesday, January 28, 14
Using RestKit: The Call
[[RKObjectManager sharedManager] getObjectsAtPath:@"jokes"
parameters:nil
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
self.jokes = mappingResult.array;
[self.tableView reloadData];
}
failure:^(RKObjectRequestOperation *operation, NSError *error) {
[self displayError:error];
}];

RKMappingResult has
count,firstObject, array,
dictionary,
and set properties
Tuesday, January 28, 14
Using RestKit: The Mappin
gf

or POST

RKObjectMapping *inverseJokeMapping = [jokeMapping inverseMapping];
RKRequestDescriptor *requestDescriptor = [RKRequestDescriptor
requestDescriptorWithMapping:inverseJokeMapping
objectClass:[Joke class]
rootKeyPath:@"jokes"
method:RKRequestMethodPOST ];
[[RKObjectManager sharedManager] addRequestDescriptor:requestDescriptor];

Tuesday, January 28, 14
it: POSTing
Using RestK
Joke *aJoke=[[Joke alloc] init];
aJoke.jokeId=@9999;
aJoke.text=@"Chuck Norris can find the end of a circle.";
[[RKObjectManager sharedManager] postObject:aJoke
path:@"jokes"
parameters:nil
success:^(RKObjectRequestOperation *operation,
RKMappingResult *mappingResult){}
failure:^(RKObjectRequestOperation *operation,
NSError *error){}];

Tuesday, January 28, 14
ome Demos
S

Tuesday, January 28, 14
Matt Galloway
Architactile
matt@architactile.com
918-808-3072

Tuesday, January 28, 14

More Related Content

What's hot

Object Storage with Gluster
Object Storage with GlusterObject Storage with Gluster
Object Storage with Gluster
Gluster.org
 
2013 PyCon SG - Building your cloud infrastructure with Python
2013 PyCon SG - Building your cloud infrastructure with Python2013 PyCon SG - Building your cloud infrastructure with Python
2013 PyCon SG - Building your cloud infrastructure with Python
George Goh
 
5. configuring multiple switch with files
5. configuring multiple switch with files5. configuring multiple switch with files
5. configuring multiple switch with files
Vishnu Vardhan
 
Blockchain Workshop - Software Freedom Day 2017
Blockchain Workshop - Software Freedom Day 2017Blockchain Workshop - Software Freedom Day 2017
Blockchain Workshop - Software Freedom Day 2017
Zied GUESMI
 
Long Tail Treasure Trove
Long Tail Treasure TroveLong Tail Treasure Trove
Long Tail Treasure Trove
Gianugo Rabellino
 
Pusherアプリの作り方
Pusherアプリの作り方Pusherアプリの作り方
Pusherアプリの作り方
Jun OHWADA
 
Node.js - A Quick Tour II
Node.js - A Quick Tour IINode.js - A Quick Tour II
Node.js - A Quick Tour II
Felix Geisendörfer
 
StackExchange.redis
StackExchange.redisStackExchange.redis
StackExchange.redis
Larry Nung
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)
Felix Geisendörfer
 
Openstack at NTT Feb 7, 2011
Openstack at NTT Feb 7, 2011Openstack at NTT Feb 7, 2011
Openstack at NTT Feb 7, 2011
Open Stack
 
LinuxKit Swarm Nodes
LinuxKit Swarm NodesLinuxKit Swarm Nodes
LinuxKit Swarm Nodes
Moby Project
 
Ac cuda c_2
Ac cuda c_2Ac cuda c_2
Ac cuda c_2
Josh Wyatt
 
Elastic search
Elastic searchElastic search
Elastic search
Torstein Hansen
 
nodester Architecture overview & roadmap
nodester Architecture overview & roadmapnodester Architecture overview & roadmap
nodester Architecture overview & roadmap
wearefractal
 
Nodester Architecture overview & roadmap
Nodester Architecture overview & roadmapNodester Architecture overview & roadmap
Nodester Architecture overview & roadmap
cmatthieu
 
Kubernetes Tutorial
Kubernetes TutorialKubernetes Tutorial
Kubernetes Tutorial
Ci Jie Li
 
Guillotina: The Asyncio REST Resource API
Guillotina: The Asyncio REST Resource APIGuillotina: The Asyncio REST Resource API
Guillotina: The Asyncio REST Resource API
Nathan Van Gheem
 
DevStack
DevStackDevStack
DevStack
Everett Toews
 
Introduction to Python Asyncio
Introduction to Python AsyncioIntroduction to Python Asyncio
Introduction to Python Asyncio
Nathan Van Gheem
 
속도체크
속도체크속도체크
속도체크
knight1128
 

What's hot (20)

Object Storage with Gluster
Object Storage with GlusterObject Storage with Gluster
Object Storage with Gluster
 
2013 PyCon SG - Building your cloud infrastructure with Python
2013 PyCon SG - Building your cloud infrastructure with Python2013 PyCon SG - Building your cloud infrastructure with Python
2013 PyCon SG - Building your cloud infrastructure with Python
 
5. configuring multiple switch with files
5. configuring multiple switch with files5. configuring multiple switch with files
5. configuring multiple switch with files
 
Blockchain Workshop - Software Freedom Day 2017
Blockchain Workshop - Software Freedom Day 2017Blockchain Workshop - Software Freedom Day 2017
Blockchain Workshop - Software Freedom Day 2017
 
Long Tail Treasure Trove
Long Tail Treasure TroveLong Tail Treasure Trove
Long Tail Treasure Trove
 
Pusherアプリの作り方
Pusherアプリの作り方Pusherアプリの作り方
Pusherアプリの作り方
 
Node.js - A Quick Tour II
Node.js - A Quick Tour IINode.js - A Quick Tour II
Node.js - A Quick Tour II
 
StackExchange.redis
StackExchange.redisStackExchange.redis
StackExchange.redis
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)
 
Openstack at NTT Feb 7, 2011
Openstack at NTT Feb 7, 2011Openstack at NTT Feb 7, 2011
Openstack at NTT Feb 7, 2011
 
LinuxKit Swarm Nodes
LinuxKit Swarm NodesLinuxKit Swarm Nodes
LinuxKit Swarm Nodes
 
Ac cuda c_2
Ac cuda c_2Ac cuda c_2
Ac cuda c_2
 
Elastic search
Elastic searchElastic search
Elastic search
 
nodester Architecture overview & roadmap
nodester Architecture overview & roadmapnodester Architecture overview & roadmap
nodester Architecture overview & roadmap
 
Nodester Architecture overview & roadmap
Nodester Architecture overview & roadmapNodester Architecture overview & roadmap
Nodester Architecture overview & roadmap
 
Kubernetes Tutorial
Kubernetes TutorialKubernetes Tutorial
Kubernetes Tutorial
 
Guillotina: The Asyncio REST Resource API
Guillotina: The Asyncio REST Resource APIGuillotina: The Asyncio REST Resource API
Guillotina: The Asyncio REST Resource API
 
DevStack
DevStackDevStack
DevStack
 
Introduction to Python Asyncio
Introduction to Python AsyncioIntroduction to Python Asyncio
Introduction to Python Asyncio
 
속도체크
속도체크속도체크
속도체크
 

Similar to Techfest 2013 No RESTKit for the Weary

Beacons, Raspberry Pi & Node.js
Beacons, Raspberry Pi & Node.jsBeacons, Raspberry Pi & Node.js
Beacons, Raspberry Pi & Node.js
Jeff Prestes
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
Whymca
 
iPhone and Rails integration
iPhone and Rails integrationiPhone and Rails integration
iPhone and Rails integration
Paul Ardeleanu
 
RESTfull with RestKit
RESTfull with RestKitRESTfull with RestKit
RESTfull with RestKit
Taras Kalapun
 
Taking Objective-C to the next level. UA Mobile 2016.
Taking Objective-C to the next level. UA Mobile 2016.Taking Objective-C to the next level. UA Mobile 2016.
Taking Objective-C to the next level. UA Mobile 2016.
UA Mobile
 
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Sarp Erdag
 
Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long
jaxconf
 
I os 13
I os 13I os 13
I os 13
信嘉 陳
 
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docxcase3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
tidwellveronique
 
MPD2011 | Сергей Клюев "RESTfull iOS with RestKit"
MPD2011 | Сергей Клюев "RESTfull iOS with RestKit"MPD2011 | Сергей Клюев "RESTfull iOS with RestKit"
MPD2011 | Сергей Клюев "RESTfull iOS with RestKit"
ITGinGer
 
iOS Development Methodology
iOS Development MethodologyiOS Development Methodology
iOS Development Methodology
SmartLogic
 
Network security Lab manual
Network security Lab manual Network security Lab manual
Network security Lab manual
Vivek Kumar Sinha
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
David Gómez García
 
Javascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJSJavascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJS
Ladislav Prskavec
 
Eddystone Beacons - Physical Web - Giving a URL to All Objects
Eddystone Beacons - Physical Web - Giving a URL to All ObjectsEddystone Beacons - Physical Web - Giving a URL to All Objects
Eddystone Beacons - Physical Web - Giving a URL to All Objects
Jeff Prestes
 
Giving a URL to All Objects using Beacons²
Giving a URL to All Objects using Beacons²Giving a URL to All Objects using Beacons²
Giving a URL to All Objects using Beacons²
All Things Open
 
Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014
Holden Karau
 
Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone Development
Giordano Scalzo
 
Physical web
Physical webPhysical web
Physical web
Jeff Prestes
 
Moar tools for asynchrony!
Moar tools for asynchrony!Moar tools for asynchrony!
Moar tools for asynchrony!
Joachim Bengtsson
 

Similar to Techfest 2013 No RESTKit for the Weary (20)

Beacons, Raspberry Pi & Node.js
Beacons, Raspberry Pi & Node.jsBeacons, Raspberry Pi & Node.js
Beacons, Raspberry Pi & Node.js
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
 
iPhone and Rails integration
iPhone and Rails integrationiPhone and Rails integration
iPhone and Rails integration
 
RESTfull with RestKit
RESTfull with RestKitRESTfull with RestKit
RESTfull with RestKit
 
Taking Objective-C to the next level. UA Mobile 2016.
Taking Objective-C to the next level. UA Mobile 2016.Taking Objective-C to the next level. UA Mobile 2016.
Taking Objective-C to the next level. UA Mobile 2016.
 
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
 
Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long
 
I os 13
I os 13I os 13
I os 13
 
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docxcase3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
 
MPD2011 | Сергей Клюев "RESTfull iOS with RestKit"
MPD2011 | Сергей Клюев "RESTfull iOS with RestKit"MPD2011 | Сергей Клюев "RESTfull iOS with RestKit"
MPD2011 | Сергей Клюев "RESTfull iOS with RestKit"
 
iOS Development Methodology
iOS Development MethodologyiOS Development Methodology
iOS Development Methodology
 
Network security Lab manual
Network security Lab manual Network security Lab manual
Network security Lab manual
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
 
Javascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJSJavascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJS
 
Eddystone Beacons - Physical Web - Giving a URL to All Objects
Eddystone Beacons - Physical Web - Giving a URL to All ObjectsEddystone Beacons - Physical Web - Giving a URL to All Objects
Eddystone Beacons - Physical Web - Giving a URL to All Objects
 
Giving a URL to All Objects using Beacons²
Giving a URL to All Objects using Beacons²Giving a URL to All Objects using Beacons²
Giving a URL to All Objects using Beacons²
 
Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014
 
Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone Development
 
Physical web
Physical webPhysical web
Physical web
 
Moar tools for asynchrony!
Moar tools for asynchrony!Moar tools for asynchrony!
Moar tools for asynchrony!
 

More from Matt Galloway

iOSDistributionOptions
iOSDistributionOptionsiOSDistributionOptions
iOSDistributionOptions
Matt Galloway
 
You Are Here: Exploring mobile proximity awareness with iBeacon
You Are Here: Exploring mobile proximity awareness with iBeaconYou Are Here: Exploring mobile proximity awareness with iBeacon
You Are Here: Exploring mobile proximity awareness with iBeacon
Matt Galloway
 
[iOSDevelopment startAt: squareOne]; @ Tulsa School of Dev 2014
[iOSDevelopment startAt: squareOne]; @ Tulsa School of Dev 2014[iOSDevelopment startAt: squareOne]; @ Tulsa School of Dev 2014
[iOSDevelopment startAt: squareOne]; @ Tulsa School of Dev 2014
Matt Galloway
 
Wire Framing Presentation
Wire Framing PresentationWire Framing Presentation
Wire Framing Presentation
Matt Galloway
 
Everything Staffing Folks Should Know About Mobile Development
Everything Staffing Folks Should Know About Mobile DevelopmentEverything Staffing Folks Should Know About Mobile Development
Everything Staffing Folks Should Know About Mobile Development
Matt Galloway
 
Tulsa TechFest 2013 - StartUp Tulsa
Tulsa TechFest 2013 - StartUp TulsaTulsa TechFest 2013 - StartUp Tulsa
Tulsa TechFest 2013 - StartUp Tulsa
Matt Galloway
 
Tulsa Dev Lunch iOS at Work
Tulsa Dev Lunch iOS at WorkTulsa Dev Lunch iOS at Work
Tulsa Dev Lunch iOS at Work
Matt Galloway
 
How to Hire A Developer
How to Hire A DeveloperHow to Hire A Developer
How to Hire A Developer
Matt Galloway
 
Tulsa Small Business Resources
Tulsa Small Business ResourcesTulsa Small Business Resources
Tulsa Small Business Resources
Matt Galloway
 
Oklahoma Tweets
Oklahoma TweetsOklahoma Tweets
Oklahoma Tweets
Matt Galloway
 
Love 1:46pm twitter event april 22 & 23, 2009
Love 1:46pm twitter event april 22 & 23, 2009Love 1:46pm twitter event april 22 & 23, 2009
Love 1:46pm twitter event april 22 & 23, 2009
Matt Galloway
 
Tulsa Area United Way Agencies' Website Assessment & Recommendations
Tulsa Area United Way Agencies' Website Assessment & RecommendationsTulsa Area United Way Agencies' Website Assessment & Recommendations
Tulsa Area United Way Agencies' Website Assessment & Recommendations
Matt Galloway
 

More from Matt Galloway (12)

iOSDistributionOptions
iOSDistributionOptionsiOSDistributionOptions
iOSDistributionOptions
 
You Are Here: Exploring mobile proximity awareness with iBeacon
You Are Here: Exploring mobile proximity awareness with iBeaconYou Are Here: Exploring mobile proximity awareness with iBeacon
You Are Here: Exploring mobile proximity awareness with iBeacon
 
[iOSDevelopment startAt: squareOne]; @ Tulsa School of Dev 2014
[iOSDevelopment startAt: squareOne]; @ Tulsa School of Dev 2014[iOSDevelopment startAt: squareOne]; @ Tulsa School of Dev 2014
[iOSDevelopment startAt: squareOne]; @ Tulsa School of Dev 2014
 
Wire Framing Presentation
Wire Framing PresentationWire Framing Presentation
Wire Framing Presentation
 
Everything Staffing Folks Should Know About Mobile Development
Everything Staffing Folks Should Know About Mobile DevelopmentEverything Staffing Folks Should Know About Mobile Development
Everything Staffing Folks Should Know About Mobile Development
 
Tulsa TechFest 2013 - StartUp Tulsa
Tulsa TechFest 2013 - StartUp TulsaTulsa TechFest 2013 - StartUp Tulsa
Tulsa TechFest 2013 - StartUp Tulsa
 
Tulsa Dev Lunch iOS at Work
Tulsa Dev Lunch iOS at WorkTulsa Dev Lunch iOS at Work
Tulsa Dev Lunch iOS at Work
 
How to Hire A Developer
How to Hire A DeveloperHow to Hire A Developer
How to Hire A Developer
 
Tulsa Small Business Resources
Tulsa Small Business ResourcesTulsa Small Business Resources
Tulsa Small Business Resources
 
Oklahoma Tweets
Oklahoma TweetsOklahoma Tweets
Oklahoma Tweets
 
Love 1:46pm twitter event april 22 & 23, 2009
Love 1:46pm twitter event april 22 & 23, 2009Love 1:46pm twitter event april 22 & 23, 2009
Love 1:46pm twitter event april 22 & 23, 2009
 
Tulsa Area United Way Agencies' Website Assessment & Recommendations
Tulsa Area United Way Agencies' Website Assessment & RecommendationsTulsa Area United Way Agencies' Website Assessment & Recommendations
Tulsa Area United Way Agencies' Website Assessment & Recommendations
 

Recently uploaded

GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
Sease
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
DianaGray10
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
christinelarrosa
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
Fwdays
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
ScyllaDB
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
Vadym Kazulkin
 

Recently uploaded (20)

GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
 

Techfest 2013 No RESTKit for the Weary

  • 1. or the Weary No RestKit f Matt Galloway Architactile matt@architactile.com 918-808-3072 Tuesday, January 28, 14
  • 2. Some Amazingly Cool Data from the “Cloud” ul* Web RESTF es Servic the “Cloud” REST-ish and JSONy. ul,“ of course, I mean * By “RESTF Tuesday, January 28, 14
  • 3. rvice Calls on iOS Web Se Define your URL NSString *url = @”http://somewebservice.com/objects.json”; Make the Call NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]]; [[NSURLConnection alloc] initWithRequest:request delegate:self]; ese delegate methods!!! Then implement all of th - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error (void)connectionDidFinishLoading:(NSURLConnection *)connection and now you have to parse the JSON in NSData into something useful... Tuesday, January 28, 14
  • 4. n is great, but... NSJSONSerializatio -(void) parseJSONIntoModel:(NSData *) jsonData { NSError *error = nil; NSDictionary *json = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:&error]; if (error!=nil) { // TODO: Insert annoying JSON error handler here. } if ([json isKindOfClass:[NSArray class]]) { //TODO: Uh. I was expecting a dictionary but apparently this is an array. Writng some handling code here. } for(NSString *key in [json allKeys]) { if ([key isEqualToString:@"user"]) { NSDictionary *userDictionary = [json objectForKey:key]; NSNumber *userId = [userDictionary objectForKey:@"id"]; RKGUser *user = [[ObjectFactory sharedFactory] userForUserId:userId]; if (user==nil) { user = [[ObjectFactory sharedFactory] newUser]; user.userId=useriD; } } . . . user.name = [userDictionary objectForKey:@"name"]; user.username = [userDictionary objectForKey:@"username"]; user.phone = [userDictionary objectForKey:@"phone"]; user.email = [userDictionary objectForKey:@"email"]; Tuesday, January 28, 14
  • 5. nter RestKit E https://github.com/RestK it /RestKit/ ing and modeling ework for consum RestKit is a fram s on iOS and OS X Tful web resource RES Tuesday, January 28, 14
  • 6. [[RKObjectManager sharedManager] getObjectsAtPath:@"objects.json" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { // Call is successful. Objects are all populated. } failure:^(RKObjectRequestOperation *operation, NSError *error) { // Call failed. }]; Tuesday, January 28, 14
  • 7. RestKit is... rce & available on GitHub * Open Sou * Built on AFNetworking Beautifully multi-threaded * eamlessly with CoreData * Integrates s o works with plain objects * Als lationships, nesting, etc. * Handles re on mapping like an ORM * Based * Very configurable , POST, PATCH, etc. ndles all REST verbs - GET * Ha y actively maintained * Ver ase seeding, search, ch of other stuff - datab * A bu n XML, etc. Tuesday, January 28, 14
  • 8. ing RestKit Install I <3 CocoaPods $ cd /path/to/MyProject $ touch Podfile $ edit Podfile platform :ios, '5.0' # Or platform :osx, '10.7' pod 'RestKit', '~> 0.20.0' $ pod install $ open MyProject.xcworkspace Tuesday, January 28, 14
  • 9. Using RestKit: The W e Tuesday, January 28, 14 b Service
  • 10. Using RestKit: The Object @interface Joke : NSObject @property (nonatomic, strong) NSNumber *jokeId; @property (nonatomic, strong) NSString *text; @end @implementation Joke @end Tuesday, January 28, 14
  • 11. Using RestKit: The Setup -(void) setupRestKit { RKObjectManager *objectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://api.icndb.com/"]]; objectManager.requestSerializationMIMEType=RKMIMETypeJSON; [RKObjectManager setSharedManager:objectManager]; . . . eps for CoreData, authentication, etc.) (There are a few extra st Tuesday, January 28, 14
  • 12. Using RestKit: The Mappin g RKObjectMapping *jokeMapping = [RKObjectMapping mappingForClass:[Joke class]]; [jokeMapping addAttributeMappingsFromDictionary:@{ @"id": @"joke": @"jokeId", @"text"}]; RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:jokeMapping method:RKRequestMethodGET pathPattern:@"jokes" keyPath:@"value" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; [[RKObjectManager sharedManager] addResponseDescriptor:responseDescriptor]; Tuesday, January 28, 14
  • 13. I <3 Singletons a singleton, so KObjectManager is R apping steps need the setup and m e, usually at app only be done onc launch. it and forget it. :) Se t Tuesday, January 28, 14
  • 14. Using RestKit: The Call [[RKObjectManager sharedManager] getObjectsAtPath:@"jokes" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { self.jokes = mappingResult.array; [self.tableView reloadData]; } failure:^(RKObjectRequestOperation *operation, NSError *error) { [self displayError:error]; }]; RKMappingResult has count,firstObject, array, dictionary, and set properties Tuesday, January 28, 14
  • 15. Using RestKit: The Mappin gf or POST RKObjectMapping *inverseJokeMapping = [jokeMapping inverseMapping]; RKRequestDescriptor *requestDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:inverseJokeMapping objectClass:[Joke class] rootKeyPath:@"jokes" method:RKRequestMethodPOST ]; [[RKObjectManager sharedManager] addRequestDescriptor:requestDescriptor]; Tuesday, January 28, 14
  • 16. it: POSTing Using RestK Joke *aJoke=[[Joke alloc] init]; aJoke.jokeId=@9999; aJoke.text=@"Chuck Norris can find the end of a circle."; [[RKObjectManager sharedManager] postObject:aJoke path:@"jokes" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult){} failure:^(RKObjectRequestOperation *operation, NSError *error){}]; Tuesday, January 28, 14