SlideShare una empresa de Scribd logo
1 de 32
Nikmesoft Ltd
Networking
Linh NGUYEN
Lecture 6
Nikmesoft Ltd
Contents
2
Overview1
Working with NSURLConnection2
Working with RESTful Web Services3
Working with JSON4
Exercise 65
Nikmesoft Ltd
Networking
Overview
3
Nikmesoft Ltd
Overview
4
ServerClient
BODY + Header
BODY + Header
Request
Response
Nikmesoft Ltd
Overview
 Header
 Field names
• http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
• Additional field names and permissible values may be defined by each
application.
 Size limits
• There are no limits to the size of each header field name or value or to the
number of headers in the standard itself. However, most servers, clients, and
proxy software impose some limits for practical and security reasons. For
example, the Apache 2.3 server by default limits each header size to 8190
bytes, and there can be at most 100 headers in a single request
5
Nikmesoft Ltd
Overview
6
Header
Content-Length 1000
Content-Type
application/x-www-
form-urlencoded
Range bytes=500-999
User-Agent Mobile
Nikmesoft Ltd
Overview
7
Request
POST
GET
Nikmesoft Ltd
Networking
NSURLConnection
8
Nikmesoft Ltd
NSURLConnection
 An NSURLConnection object provides support to perform
the loading of a URL request. The interface for
NSURLConnection is sparse, providing only the controls to
start and cancel asynchronous loads of a URL request.
 NSURLConnection’s delegate methods—defined by the
NSURLConnectionDelegate protocol—allow an object to
receive informational callbacks about the asynchronous load
of a URL request.
9
Nikmesoft Ltd
NSURLConnection
 NSURLConnection has a convenience class method,
sendSynchronousRequest:returningResponse:error:, to
load a URL request synchronously.
10
Nikmesoft Ltd
NSURLConnection
 Preflighting a Connection Request
 + canHandleRequest:
 Connection URL Information
 – originalRequest
 – currentRequest
 Loading Data Synchronously
 + sendSynchronousRequest:returningResponse:error:
11
Nikmesoft Ltd
NSURLConnection
 Loading Data Asynchronously
 + connectionWithRequest:delegate:
 – initWithRequest:delegate:
 – initWithRequest:delegate:startImmediately:
 + sendAsynchronousRequest:queue:completionHandler:
 – start
 Stopping a Connection
 – cancel
12
Nikmesoft Ltd
NSURLConnection
13
Nikmesoft Ltd
NSURLConnection
14
Nikmesoft Ltd
Networking
Working with RESTful Web Services
15
Nikmesoft Ltd
Working with RESTful Web Services
16
Nikmesoft Ltd
Working with RESTful Web Services
17
DELETE
Client
POST
GET
PUT
RESTful Web
services DB
Nikmesoft Ltd
Working with RESTful Web Services
18
XML
JSON
OTHER
REQUEST
or
RESPONSE
URL
HEADER
BODY
Nikmesoft Ltd
Working with RESTful Web Services
19
XML
JSON
OTHER
Nikmesoft Ltd
Working with RESTful Web Services
20
URL
HEADER
BODY
POST
http://nikmesoft.com/steven/vietfooding/users/login.json
api_key = a30e38ce87e30dd2a6f7e858ce68dcc3
email = test02@gmail.com
password = 1
Nikmesoft Ltd
Working with RESTful Web Services
21
Nikmesoft Ltd
Working with RESTful Web Services
22
URL
HEADER
GET
http://nikmesoft.com/steven/vietfooding/users/?id=1/
api_key = a30e38ce87e30dd2a6f7e858ce68dcc3
Nikmesoft Ltd
Web services
Working with JSON
23
Nikmesoft Ltd
Working with JSON
 What is JSON?
 JSON or JavaScript Object Notation, is a text-based open
standard designed for human-readable data interchange. It is
derived from the JavaScript scripting language for representing
simple data structures and associative arrays, called objects.
Despite its relationship to JavaScript, it is language-independent,
with parsers available for many languages.
 The JSON format is often used for serializing and transmitting
structured data over a network connection. It is used primarily to
transmit data between a server and web application, serving as an
alternative to XML.
24
Nikmesoft Ltd
Working with JSON
 JSON’s basic types are:
 Number
 String (double-quoted Unicode, with backslash escaping)
 Boolean (true or false)
25
Nikmesoft Ltd
Working with JSON
 JSON’s basic types are:
 Array (an ordered sequence of values, comma-separated and
enclosed in square brackets; the values do not need to be of the
same type)
 Object (an unordered collection of key:value pairs with the ':'
character separating the key and the value, comma-separated and
enclosed in curly braces; the keys must be strings and should be
distinct from each other)
 null (empty)
26
Nikmesoft Ltd
Working with JSON
27
Nikmesoft Ltd
Working with JSON
 NSJSONSerialization
 You use the NSJSONSerialization class to convert JSON to
Foundation objects and convert Foundation objects to JSON.
 An object that may be converted to JSON must have the following
properties:
• The top level object is an NSArray or NSDictionary.
• All objects are instances of NSString, NSNumber, NSArray, NSDictionary, or
NSNull.
• All dictionary keys are instances of NSString.
• Numbers are not NaN or infinity.
28
Nikmesoft Ltd
Working with JSON
 NSJSONSerialization
 Other rules may apply. Calling isValidJSONObject: or attempting a
conversion are the definitive ways to tell if a given object can be
converted to JSON data.
 Creating a JSON Object
• + JSONObjectWithData:options:error:
• + JSONObjectWithStream:options:error:
 Creating JSON Data
• + dataWithJSONObject:options:error:
• + writeJSONObject:toStream:options:error:
• + isValidJSONObject:
29
Nikmesoft Ltd
Working with JSON
 NSJSONSerialization
 JSONObjectWithData:options:error:
• NSJSONReadingMutableContainers
– Specifies that arrays and dictionaries are created as mutable objects.
• NSJSONReadingMutableLeaves
– Specifies that leaf strings in the JSON object graph are created as instances of NSMutableString.
• NSJSONReadingAllowFragments
– Specifies that the parser should allow top-level objects that are not an instance of NSArray or
NSDictionary.
30
Nikmesoft Ltd
Exercise 6
31
Nikmesoft Ltd
32

Más contenido relacionado

La actualidad más candente

Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)David McCarter
 
Whats new in MongoDB 1.4
Whats new in MongoDB 1.4Whats new in MongoDB 1.4
Whats new in MongoDB 1.4RedBeard0531
 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchMongoDB
 
OData, Open Data Protocol. A brief introduction
OData, Open Data Protocol. A brief introductionOData, Open Data Protocol. A brief introduction
OData, Open Data Protocol. A brief introductionEugenio Lentini
 
MongoDB.local Berlin: MongoDB Mobile
MongoDB.local Berlin: MongoDB MobileMongoDB.local Berlin: MongoDB Mobile
MongoDB.local Berlin: MongoDB MobileMongoDB
 
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San FranciscoMySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San FranciscoDave Stokes
 
Database Trends for Modern Applications: Why the Database You Choose Matters
Database Trends for Modern Applications: Why the Database You Choose Matters Database Trends for Modern Applications: Why the Database You Choose Matters
Database Trends for Modern Applications: Why the Database You Choose Matters MongoDB
 
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...MongoDB
 
OrientDB the graph database
OrientDB the graph databaseOrientDB the graph database
OrientDB the graph databaseArtem Orobets
 
OrientDB & Node.js Overview - JS.Everywhere() KW
OrientDB & Node.js Overview - JS.Everywhere() KWOrientDB & Node.js Overview - JS.Everywhere() KW
OrientDB & Node.js Overview - JS.Everywhere() KWgmccarvell
 
FIWARE Global Summit - NGSI-LD: Modelling, Linking and Utilizing Context Info...
FIWARE Global Summit - NGSI-LD: Modelling, Linking and Utilizing Context Info...FIWARE Global Summit - NGSI-LD: Modelling, Linking and Utilizing Context Info...
FIWARE Global Summit - NGSI-LD: Modelling, Linking and Utilizing Context Info...FIWARE
 
MongoDB Replication and Sharding
MongoDB Replication and ShardingMongoDB Replication and Sharding
MongoDB Replication and ShardingTharun Srinivasa
 
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers ProgramSession 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers ProgramFIWARE
 
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDBMongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDBMongoDB
 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQLLuca Garulli
 
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...MongoDB
 
FIWARE Global Summit - NGSI-LD – an Evolution from NGSIv2
FIWARE Global Summit - NGSI-LD – an Evolution from NGSIv2FIWARE Global Summit - NGSI-LD – an Evolution from NGSIv2
FIWARE Global Summit - NGSI-LD – an Evolution from NGSIv2FIWARE
 
Topic 12: NoSQL in Action
Topic 12: NoSQL in ActionTopic 12: NoSQL in Action
Topic 12: NoSQL in ActionZubair Nabi
 
Webinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and JavaWebinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and JavaMongoDB
 

La actualidad más candente (20)

Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)
 
Whats new in MongoDB 1.4
Whats new in MongoDB 1.4Whats new in MongoDB 1.4
Whats new in MongoDB 1.4
 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB Stitch
 
MongoDB + Spring
MongoDB + SpringMongoDB + Spring
MongoDB + Spring
 
OData, Open Data Protocol. A brief introduction
OData, Open Data Protocol. A brief introductionOData, Open Data Protocol. A brief introduction
OData, Open Data Protocol. A brief introduction
 
MongoDB.local Berlin: MongoDB Mobile
MongoDB.local Berlin: MongoDB MobileMongoDB.local Berlin: MongoDB Mobile
MongoDB.local Berlin: MongoDB Mobile
 
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San FranciscoMySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
 
Database Trends for Modern Applications: Why the Database You Choose Matters
Database Trends for Modern Applications: Why the Database You Choose Matters Database Trends for Modern Applications: Why the Database You Choose Matters
Database Trends for Modern Applications: Why the Database You Choose Matters
 
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
 
OrientDB the graph database
OrientDB the graph databaseOrientDB the graph database
OrientDB the graph database
 
OrientDB & Node.js Overview - JS.Everywhere() KW
OrientDB & Node.js Overview - JS.Everywhere() KWOrientDB & Node.js Overview - JS.Everywhere() KW
OrientDB & Node.js Overview - JS.Everywhere() KW
 
FIWARE Global Summit - NGSI-LD: Modelling, Linking and Utilizing Context Info...
FIWARE Global Summit - NGSI-LD: Modelling, Linking and Utilizing Context Info...FIWARE Global Summit - NGSI-LD: Modelling, Linking and Utilizing Context Info...
FIWARE Global Summit - NGSI-LD: Modelling, Linking and Utilizing Context Info...
 
MongoDB Replication and Sharding
MongoDB Replication and ShardingMongoDB Replication and Sharding
MongoDB Replication and Sharding
 
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers ProgramSession 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
Session 2 - NGSI-LD primer & Smart Data Models | Train the Trainers Program
 
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDBMongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQL
 
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...
 
FIWARE Global Summit - NGSI-LD – an Evolution from NGSIv2
FIWARE Global Summit - NGSI-LD – an Evolution from NGSIv2FIWARE Global Summit - NGSI-LD – an Evolution from NGSIv2
FIWARE Global Summit - NGSI-LD – an Evolution from NGSIv2
 
Topic 12: NoSQL in Action
Topic 12: NoSQL in ActionTopic 12: NoSQL in Action
Topic 12: NoSQL in Action
 
Webinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and JavaWebinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and Java
 

Destacado

[iOS] Introduction to iOS Programming
[iOS] Introduction to iOS Programming[iOS] Introduction to iOS Programming
[iOS] Introduction to iOS ProgrammingNikmesoft Ltd
 
[Android] Introduction to Android Programming
[Android] Introduction to Android Programming[Android] Introduction to Android Programming
[Android] Introduction to Android ProgrammingNikmesoft Ltd
 
[Android] Basic Widgets and Containers
[Android] Basic Widgets and Containers[Android] Basic Widgets and Containers
[Android] Basic Widgets and ContainersNikmesoft Ltd
 
[Android] Using Selection Widgets
[Android] Using Selection Widgets[Android] Using Selection Widgets
[Android] Using Selection WidgetsNikmesoft Ltd
 
[Android] Data Storage
[Android] Data Storage[Android] Data Storage
[Android] Data StorageNikmesoft Ltd
 
iOS: Overview, Architecture, Development & Versions
iOS: Overview, Architecture, Development & Versions iOS: Overview, Architecture, Development & Versions
iOS: Overview, Architecture, Development & Versions Sandra Kerbage
 
iOS Basics: Introducing the iPad, iPhone, and iCloud
iOS Basics: Introducing the iPad, iPhone, and iCloudiOS Basics: Introducing the iPad, iPhone, and iCloud
iOS Basics: Introducing the iPad, iPhone, and iCloudSt. Petersburg College
 
Linear Regression
Linear RegressionLinear Regression
Linear RegressionRyan Sain
 
[Android] Intent and Activity
[Android] Intent and Activity[Android] Intent and Activity
[Android] Intent and ActivityNikmesoft Ltd
 
[Android] Widget Event Handling
[Android] Widget Event Handling[Android] Widget Event Handling
[Android] Widget Event HandlingNikmesoft Ltd
 
iOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersRyanISI
 
Pentesting iOS Applications
Pentesting iOS ApplicationsPentesting iOS Applications
Pentesting iOS Applicationsjasonhaddix
 
Introduction to Swift programming language.
Introduction to Swift programming language.Introduction to Swift programming language.
Introduction to Swift programming language.Icalia Labs
 
[iOS] Basic UI Elements
[iOS] Basic UI Elements[iOS] Basic UI Elements
[iOS] Basic UI ElementsNikmesoft Ltd
 

Destacado (20)

[iOS] Introduction to iOS Programming
[iOS] Introduction to iOS Programming[iOS] Introduction to iOS Programming
[iOS] Introduction to iOS Programming
 
[iOS] Navigation
[iOS] Navigation[iOS] Navigation
[iOS] Navigation
 
[Android] Introduction to Android Programming
[Android] Introduction to Android Programming[Android] Introduction to Android Programming
[Android] Introduction to Android Programming
 
Apple iOS
Apple iOSApple iOS
Apple iOS
 
[Android] Basic Widgets and Containers
[Android] Basic Widgets and Containers[Android] Basic Widgets and Containers
[Android] Basic Widgets and Containers
 
[Android] Using Selection Widgets
[Android] Using Selection Widgets[Android] Using Selection Widgets
[Android] Using Selection Widgets
 
[Android] Data Storage
[Android] Data Storage[Android] Data Storage
[Android] Data Storage
 
iOS: Overview, Architecture, Development & Versions
iOS: Overview, Architecture, Development & Versions iOS: Overview, Architecture, Development & Versions
iOS: Overview, Architecture, Development & Versions
 
iOS Basics: Introducing the iPad, iPhone, and iCloud
iOS Basics: Introducing the iPad, iPhone, and iCloudiOS Basics: Introducing the iPad, iPhone, and iCloud
iOS Basics: Introducing the iPad, iPhone, and iCloud
 
Linear Regression
Linear RegressionLinear Regression
Linear Regression
 
A seminar report on i cloud
A  seminar report on i cloudA  seminar report on i cloud
A seminar report on i cloud
 
Objective-C
Objective-CObjective-C
Objective-C
 
[Android] Intent and Activity
[Android] Intent and Activity[Android] Intent and Activity
[Android] Intent and Activity
 
[Android] Widget Event Handling
[Android] Widget Event Handling[Android] Widget Event Handling
[Android] Widget Event Handling
 
iOS Application Penetration Testing
iOS Application Penetration TestingiOS Application Penetration Testing
iOS Application Penetration Testing
 
iOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for Beginners
 
Pentesting iOS Applications
Pentesting iOS ApplicationsPentesting iOS Applications
Pentesting iOS Applications
 
Introduction to Swift programming language.
Introduction to Swift programming language.Introduction to Swift programming language.
Introduction to Swift programming language.
 
[iOS] Basic UI Elements
[iOS] Basic UI Elements[iOS] Basic UI Elements
[iOS] Basic UI Elements
 
Ios operating system
Ios operating systemIos operating system
Ios operating system
 

Similar a [iOS] Networking

Slides: Moving from a Relational Model to NoSQL
Slides: Moving from a Relational Model to NoSQLSlides: Moving from a Relational Model to NoSQL
Slides: Moving from a Relational Model to NoSQLDATAVERSITY
 
GraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: ScaleGraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: ScaleNeo4j
 
Web services Hand_Out
Web services Hand_OutWeb services Hand_Out
Web services Hand_OutKumar Gupta
 
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5Keshav Murthy
 
Yet another json rpc library (mole rpc)
Yet another json rpc library (mole rpc)Yet another json rpc library (mole rpc)
Yet another json rpc library (mole rpc)Viktor Turskyi
 
Eagle6 mongo dc revised
Eagle6 mongo dc revisedEagle6 mongo dc revised
Eagle6 mongo dc revisedMongoDB
 
Eagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational AwarenessEagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational AwarenessMongoDB
 
AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)
AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)
AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)Amazon Web Services Korea
 
Things YouShould Be Doing When Using Cassandra Drivers
Things YouShould Be Doing When Using Cassandra DriversThings YouShould Be Doing When Using Cassandra Drivers
Things YouShould Be Doing When Using Cassandra DriversRebecca Mills
 
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014Puppet
 
Delivering High Performance Websites with NGINX
Delivering High Performance Websites with NGINXDelivering High Performance Websites with NGINX
Delivering High Performance Websites with NGINXNGINX, Inc.
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersoazabir
 
Con fess 2013-sse-websockets-json-bhakti
Con fess 2013-sse-websockets-json-bhaktiCon fess 2013-sse-websockets-json-bhakti
Con fess 2013-sse-websockets-json-bhaktiBhakti Mehta
 
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...Tammy Bednar
 
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Amazon Web Services
 
Data Integration through Data Virtualization (SQL Server Konferenz 2019)
Data Integration through Data Virtualization (SQL Server Konferenz 2019)Data Integration through Data Virtualization (SQL Server Konferenz 2019)
Data Integration through Data Virtualization (SQL Server Konferenz 2019)Cathrine Wilhelmsen
 
Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IWeb Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IAnuchit Chalothorn
 
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...PROIDEA
 

Similar a [iOS] Networking (20)

Slides: Moving from a Relational Model to NoSQL
Slides: Moving from a Relational Model to NoSQLSlides: Moving from a Relational Model to NoSQL
Slides: Moving from a Relational Model to NoSQL
 
GraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: ScaleGraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: Scale
 
Web services Hand_Out
Web services Hand_OutWeb services Hand_Out
Web services Hand_Out
 
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
N1QL+GSI: Language and Performance Improvements in Couchbase 5.0 and 5.5
 
Yet another json rpc library (mole rpc)
Yet another json rpc library (mole rpc)Yet another json rpc library (mole rpc)
Yet another json rpc library (mole rpc)
 
Eagle6 mongo dc revised
Eagle6 mongo dc revisedEagle6 mongo dc revised
Eagle6 mongo dc revised
 
Eagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational AwarenessEagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational Awareness
 
AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)
AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)
AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)
 
Things YouShould Be Doing When Using Cassandra Drivers
Things YouShould Be Doing When Using Cassandra DriversThings YouShould Be Doing When Using Cassandra Drivers
Things YouShould Be Doing When Using Cassandra Drivers
 
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
 
Delivering High Performance Websites with NGINX
Delivering High Performance Websites with NGINXDelivering High Performance Websites with NGINX
Delivering High Performance Websites with NGINX
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of users
 
Con fess 2013-sse-websockets-json-bhakti
Con fess 2013-sse-websockets-json-bhaktiCon fess 2013-sse-websockets-json-bhakti
Con fess 2013-sse-websockets-json-bhakti
 
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...
Database@Home - Data Driven : Loading, Indexing, and Searching with Text and ...
 
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
Integrating Infrastructure as Code into a Continuous Delivery Pipeline | AWS ...
 
Data Integration through Data Virtualization (SQL Server Konferenz 2019)
Data Integration through Data Virtualization (SQL Server Konferenz 2019)Data Integration through Data Virtualization (SQL Server Konferenz 2019)
Data Integration through Data Virtualization (SQL Server Konferenz 2019)
 
Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IWeb Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day I
 
Elastic{ON} 2017 Recap
Elastic{ON} 2017 RecapElastic{ON} 2017 Recap
Elastic{ON} 2017 Recap
 
ASP.NET vNext ANUG 20140817
ASP.NET vNext ANUG 20140817ASP.NET vNext ANUG 20140817
ASP.NET vNext ANUG 20140817
 
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...
 

Más de Nikmesoft Ltd

[Android] Multimedia Programming
[Android] Multimedia Programming[Android] Multimedia Programming
[Android] Multimedia ProgrammingNikmesoft Ltd
 
[Android] Android Animation
[Android] Android Animation[Android] Android Animation
[Android] Android AnimationNikmesoft Ltd
 
[Android] 2D Graphics
[Android] 2D Graphics[Android] 2D Graphics
[Android] 2D GraphicsNikmesoft Ltd
 
[Android] Services and Broadcast Receivers
[Android] Services and Broadcast Receivers[Android] Services and Broadcast Receivers
[Android] Services and Broadcast ReceiversNikmesoft Ltd
 
[Android] Web services
[Android] Web services[Android] Web services
[Android] Web servicesNikmesoft Ltd
 
[Android] Multiple Background Threads
[Android] Multiple Background Threads[Android] Multiple Background Threads
[Android] Multiple Background ThreadsNikmesoft Ltd
 
[Android] Maps, Geocoding and Location-Based Services
[Android] Maps, Geocoding and Location-Based Services[Android] Maps, Geocoding and Location-Based Services
[Android] Maps, Geocoding and Location-Based ServicesNikmesoft Ltd
 

Más de Nikmesoft Ltd (7)

[Android] Multimedia Programming
[Android] Multimedia Programming[Android] Multimedia Programming
[Android] Multimedia Programming
 
[Android] Android Animation
[Android] Android Animation[Android] Android Animation
[Android] Android Animation
 
[Android] 2D Graphics
[Android] 2D Graphics[Android] 2D Graphics
[Android] 2D Graphics
 
[Android] Services and Broadcast Receivers
[Android] Services and Broadcast Receivers[Android] Services and Broadcast Receivers
[Android] Services and Broadcast Receivers
 
[Android] Web services
[Android] Web services[Android] Web services
[Android] Web services
 
[Android] Multiple Background Threads
[Android] Multiple Background Threads[Android] Multiple Background Threads
[Android] Multiple Background Threads
 
[Android] Maps, Geocoding and Location-Based Services
[Android] Maps, Geocoding and Location-Based Services[Android] Maps, Geocoding and Location-Based Services
[Android] Maps, Geocoding and Location-Based Services
 

[iOS] Networking

  • 2. Nikmesoft Ltd Contents 2 Overview1 Working with NSURLConnection2 Working with RESTful Web Services3 Working with JSON4 Exercise 65
  • 4. Nikmesoft Ltd Overview 4 ServerClient BODY + Header BODY + Header Request Response
  • 5. Nikmesoft Ltd Overview  Header  Field names • http://en.wikipedia.org/wiki/List_of_HTTP_header_fields • Additional field names and permissible values may be defined by each application.  Size limits • There are no limits to the size of each header field name or value or to the number of headers in the standard itself. However, most servers, clients, and proxy software impose some limits for practical and security reasons. For example, the Apache 2.3 server by default limits each header size to 8190 bytes, and there can be at most 100 headers in a single request 5
  • 9. Nikmesoft Ltd NSURLConnection  An NSURLConnection object provides support to perform the loading of a URL request. The interface for NSURLConnection is sparse, providing only the controls to start and cancel asynchronous loads of a URL request.  NSURLConnection’s delegate methods—defined by the NSURLConnectionDelegate protocol—allow an object to receive informational callbacks about the asynchronous load of a URL request. 9
  • 10. Nikmesoft Ltd NSURLConnection  NSURLConnection has a convenience class method, sendSynchronousRequest:returningResponse:error:, to load a URL request synchronously. 10
  • 11. Nikmesoft Ltd NSURLConnection  Preflighting a Connection Request  + canHandleRequest:  Connection URL Information  – originalRequest  – currentRequest  Loading Data Synchronously  + sendSynchronousRequest:returningResponse:error: 11
  • 12. Nikmesoft Ltd NSURLConnection  Loading Data Asynchronously  + connectionWithRequest:delegate:  – initWithRequest:delegate:  – initWithRequest:delegate:startImmediately:  + sendAsynchronousRequest:queue:completionHandler:  – start  Stopping a Connection  – cancel 12
  • 15. Nikmesoft Ltd Networking Working with RESTful Web Services 15
  • 16. Nikmesoft Ltd Working with RESTful Web Services 16
  • 17. Nikmesoft Ltd Working with RESTful Web Services 17 DELETE Client POST GET PUT RESTful Web services DB
  • 18. Nikmesoft Ltd Working with RESTful Web Services 18 XML JSON OTHER REQUEST or RESPONSE URL HEADER BODY
  • 19. Nikmesoft Ltd Working with RESTful Web Services 19 XML JSON OTHER
  • 20. Nikmesoft Ltd Working with RESTful Web Services 20 URL HEADER BODY POST http://nikmesoft.com/steven/vietfooding/users/login.json api_key = a30e38ce87e30dd2a6f7e858ce68dcc3 email = test02@gmail.com password = 1
  • 21. Nikmesoft Ltd Working with RESTful Web Services 21
  • 22. Nikmesoft Ltd Working with RESTful Web Services 22 URL HEADER GET http://nikmesoft.com/steven/vietfooding/users/?id=1/ api_key = a30e38ce87e30dd2a6f7e858ce68dcc3
  • 24. Nikmesoft Ltd Working with JSON  What is JSON?  JSON or JavaScript Object Notation, is a text-based open standard designed for human-readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects. Despite its relationship to JavaScript, it is language-independent, with parsers available for many languages.  The JSON format is often used for serializing and transmitting structured data over a network connection. It is used primarily to transmit data between a server and web application, serving as an alternative to XML. 24
  • 25. Nikmesoft Ltd Working with JSON  JSON’s basic types are:  Number  String (double-quoted Unicode, with backslash escaping)  Boolean (true or false) 25
  • 26. Nikmesoft Ltd Working with JSON  JSON’s basic types are:  Array (an ordered sequence of values, comma-separated and enclosed in square brackets; the values do not need to be of the same type)  Object (an unordered collection of key:value pairs with the ':' character separating the key and the value, comma-separated and enclosed in curly braces; the keys must be strings and should be distinct from each other)  null (empty) 26
  • 28. Nikmesoft Ltd Working with JSON  NSJSONSerialization  You use the NSJSONSerialization class to convert JSON to Foundation objects and convert Foundation objects to JSON.  An object that may be converted to JSON must have the following properties: • The top level object is an NSArray or NSDictionary. • All objects are instances of NSString, NSNumber, NSArray, NSDictionary, or NSNull. • All dictionary keys are instances of NSString. • Numbers are not NaN or infinity. 28
  • 29. Nikmesoft Ltd Working with JSON  NSJSONSerialization  Other rules may apply. Calling isValidJSONObject: or attempting a conversion are the definitive ways to tell if a given object can be converted to JSON data.  Creating a JSON Object • + JSONObjectWithData:options:error: • + JSONObjectWithStream:options:error:  Creating JSON Data • + dataWithJSONObject:options:error: • + writeJSONObject:toStream:options:error: • + isValidJSONObject: 29
  • 30. Nikmesoft Ltd Working with JSON  NSJSONSerialization  JSONObjectWithData:options:error: • NSJSONReadingMutableContainers – Specifies that arrays and dictionaries are created as mutable objects. • NSJSONReadingMutableLeaves – Specifies that leaf strings in the JSON object graph are created as instances of NSMutableString. • NSJSONReadingAllowFragments – Specifies that the parser should allow top-level objects that are not an instance of NSArray or NSDictionary. 30