SlideShare une entreprise Scribd logo
1  sur  22
iOS Training
(Advanced)
Gurpreet Singh
Sriram Viswanathan

Yahoo! Confidential

1
Topics
 Using custom delegate and protocols
 Saving and Restoring the Application State

 Introduction to NSURLConnection
 Hands on example for
 Fetching data from server
 Using Table View Controller
 Populating Data in a Table
 Refreshing Data

 Deploying your app on a device

Yahoo! Confidential

2
Using custom delegate and protocols
Defining Protocol
@protocol DataConsumerDelegate
// Method to handle response of the rest connection call
- (void) finishedReceivingData: (NSData *) data;
@end

Conforming to protocol
@interface MyDataConsumer : NSObject <DataConsumerDelegate>
@end
@implementation MyDataConsumer
- (void) finishedReceivingData: (NSData *) data {
// HANDLE THE DATA
}
@end

Yahoo! Confidential

3
Using custom delegate and protocols
Using delegate
@interface AsynchronousRestConnection : NSObject {
id<DataConsumerDelegate> dataConsumerDelegate;
}
// Used to store delgate object (it must conform to DataConsumerDelegateprotocol)
@property (nonatomic, weak) id<DataConsumerDelegate> dataConsumerDelegate;
- (void) getData;

@end
@implementation AsynchronousRestConnection
@synthesize dataConsumerDelegate;
- (void) getData {
// GET DATA AND STORE IT IN data
// YOU CAN DO MULTI QUERY AND MERGE OUTPUT
[self.dataConsumerDelegate finishedReceivingData:data];
}
@end

Yahoo! Confidential

4
Using custom delegate and protocols
Updating the MyDataConsumer class to use AsynchronousRestConnection
@interface MyDataConsumer : NSObject <DataConsumerDelegate>
- (void) getDataFromApi;
@end
@implementation MyDataConsumer
- (void) finishedReceivingData: (NSData *) data {
// HANDLE THE DATA
}
- (void) getDataFromApi {
AsynchronousRestConnection *arc = [[AsynchronousRestConnection alloc] init];
arc.dataConsumerDelegate = self;
// CONSUME DATA

}
@end

Yahoo! Confidential

5
Topics
 Using custom delegate and protocols
 Saving and Restoring the Application State

 Introduction to NSURLConnection
 Hands on example for
 Fetching data from server
 Using Table View Controller
 Populating Data in a Table
 Refreshing Data

 Deploying your app on a device

Yahoo! Confidential

6
Saving and Restoring Application State
During the preservation and restoration process, your app has a handful of
responsibilities.

During preservation, your app is responsible for:
 Telling UIKit that it supports state preservation.
 Telling UIKit which view controllers and views should be preserved.
 Encoding relevant data for any preserved objects.
During restoration, your app is responsible for:
 Telling UIKit that it supports state restoration.
 Providing (or creating) the objects that are requested by UIKit.
 Decoding the state of your preserved objects and using it to return the
object to its previous state.

Yahoo! Confidential

7
Saving and Restoring Application State
High-level flow interface preservation

Yahoo! Confidential

8
Saving and Restoring Application State
High-level flow for restoring your user interface

Yahoo! Confidential

9
Topics
 Using custom delegate and protocols
 Saving and Restoring the Application State

 Introduction to NSURLConnection
 Hands on example for
 Fetching data from server
 Using Table View Controller
 Populating Data in a Table
 Refreshing Data

 Deploying your app on a device

Yahoo! Confidential

10
Introduction to NSURLConnection
 Asynchronous Request
 Synchronous Request

 POST request
 Using Connection Timeout
 Cache Policies

Yahoo! Confidential

11
Asynchronous Request
To fetch some data, we’ll follow these 3 basic steps:
 Have our class conform to the NSURLConnectionDelegate protocol and
declare a var to store the response data
 Implement the NSURLConnectionDelegate protocol methods
 Create an instance of NSURLRequest and NSURLConnection to kick off
the request

Yahoo! Confidential

12
Asynchronous Request
Step 1:

Yahoo! Confidential

13
Asynchronous Request
Step 2:

Yahoo! Confidential

14
Asynchronous Request
Step 3:

Yahoo! Confidential

15
Asynchronous Request
Step 4:
 First connection:didReceiveResponse will be hit, indicating that the server
has responded.
 Then the handler, connection:didReceiveData: will be hit several times.
 This is where you’ll append the latest data to the response data variable
you declared in Step 1.
 Then finally, connectionDidFinishLoading: will be hit and you can parse
the response data variable.

Yahoo! Confidential

16
POST Request
A synchronous request looks like the below:

 You’ll set the HTTPMethod property to POST

 You’ll assign the header fields and value in the body
 Ensure that you’re using an instance of NSMutableURLRequest because
NSURLRequest is immutable.
Yahoo! Confidential

17
Using Connection Timeout
Using Connection Timeout



If you want to set a timeout for your data retrieval, you can set the timeoutInterval
property of your NSURLRequest.



Ensure that you’re using an instance of NSMutableURLRequest because
NSURLRequest is immutable.

Yahoo! Confidential

18
Cache Policies
To specify how your data should be cached locally, you can set a cache
policy with your NSURLRequest.
Following snippet shows you how you can define a cache policy and a
timeout.

 If you don’t specify any caching policy with your NSURLRequest, then it
will try to conform to whatever the protocol states.
 For example, with HTTP it will look at the server response headers and try
to conform to what it dictates about caching.

Yahoo! Confidential

19
Topics
 Using custom delegate and protocols
 Saving and Restoring the Application State

 Introduction to NSURLConnection
 Hands on example for
 Fetching data from server
 Using Table View Controller
 Populating Data in a Table
 Refreshing Data

 Deploying your app on a device

Yahoo! Confidential

20
Topics
 Using custom delegate and protocols
 Saving and Restoring the Application State

 Introduction to NSURLConnection
 Hands on example for
 Fetching data from server
 Using Table View Controller
 Populating Data in a Table
 Refreshing Data

 Deploying your app on a device

Yahoo! Confidential

21
Deploying your app on a device
Steps to deploy your app on a device
Step 1: iOS Developer Program (iPhone provision portal)
Step 2: Create a Certificate Signing Request
Step 3: Create a Development Certificate
Step 4: Adding a Device
Step 5: Create an App ID
Step 6: Create a Provisioning Profile
Step 7: Configuring the Project
Step 8: Build and Run
For detail refer:
http://mobile.tutsplus.com/tutorials/iphone/how-to-test-your-apps-on-physical-iosdevices/
Yahoo! Confidential

22

Contenu connexe

Tendances

PyCon DE 2013 - Table Partitioning with Django
PyCon DE 2013 - Table Partitioning with DjangoPyCon DE 2013 - Table Partitioning with Django
PyCon DE 2013 - Table Partitioning with DjangoMax Tepkeev
 
ABPerformance Quick Tour
ABPerformance Quick TourABPerformance Quick Tour
ABPerformance Quick TourActive Base
 
secure data transfer and deletion from counting bloom filter in cloud computing.
secure data transfer and deletion from counting bloom filter in cloud computing.secure data transfer and deletion from counting bloom filter in cloud computing.
secure data transfer and deletion from counting bloom filter in cloud computing.Venkat Projects
 
Towards Secure and Dependable Storage Services in Cloud Computing
Towards Secure and Dependable Storage Services in Cloud  Computing Towards Secure and Dependable Storage Services in Cloud  Computing
Towards Secure and Dependable Storage Services in Cloud Computing IJMER
 
Attribute based storage supporting
Attribute based storage supporting Attribute based storage supporting
Attribute based storage supporting CloudTechnologies
 
M-Tech Project Attribute-Based Storage Supporting Secure Deduplication of Enc...
M-Tech Project Attribute-Based Storage Supporting Secure Deduplication of Enc...M-Tech Project Attribute-Based Storage Supporting Secure Deduplication of Enc...
M-Tech Project Attribute-Based Storage Supporting Secure Deduplication of Enc...CloudTechnologies
 
Towards secure and dependable storage service in cloud
Towards secure and dependable storage service in cloudTowards secure and dependable storage service in cloud
Towards secure and dependable storage service in cloudsibidlegend
 
Ado.Net Architecture
Ado.Net ArchitectureAdo.Net Architecture
Ado.Net ArchitectureUmar Farooq
 
Towards secure and dependable storage
Towards secure and dependable storageTowards secure and dependable storage
Towards secure and dependable storageKhaja Moiz Uddin
 
Parameter substitution in Aginity Workbench
Parameter substitution in Aginity WorkbenchParameter substitution in Aginity Workbench
Parameter substitution in Aginity WorkbenchMary Uguet
 
Oracle performance tuning
Oracle performance tuningOracle performance tuning
Oracle performance tuningvksgarg
 
Panda public auditing for shared data with efficient user revocation in the c...
Panda public auditing for shared data with efficient user revocation in the c...Panda public auditing for shared data with efficient user revocation in the c...
Panda public auditing for shared data with efficient user revocation in the c...IGEEKS TECHNOLOGIES
 

Tendances (15)

PyCon DE 2013 - Table Partitioning with Django
PyCon DE 2013 - Table Partitioning with DjangoPyCon DE 2013 - Table Partitioning with Django
PyCon DE 2013 - Table Partitioning with Django
 
ABPerformance Quick Tour
ABPerformance Quick TourABPerformance Quick Tour
ABPerformance Quick Tour
 
secure data transfer and deletion from counting bloom filter in cloud computing.
secure data transfer and deletion from counting bloom filter in cloud computing.secure data transfer and deletion from counting bloom filter in cloud computing.
secure data transfer and deletion from counting bloom filter in cloud computing.
 
Towards Secure and Dependable Storage Services in Cloud Computing
Towards Secure and Dependable Storage Services in Cloud  Computing Towards Secure and Dependable Storage Services in Cloud  Computing
Towards Secure and Dependable Storage Services in Cloud Computing
 
Attribute based storage supporting
Attribute based storage supporting Attribute based storage supporting
Attribute based storage supporting
 
M-Tech Project Attribute-Based Storage Supporting Secure Deduplication of Enc...
M-Tech Project Attribute-Based Storage Supporting Secure Deduplication of Enc...M-Tech Project Attribute-Based Storage Supporting Secure Deduplication of Enc...
M-Tech Project Attribute-Based Storage Supporting Secure Deduplication of Enc...
 
Towards secure and dependable storage service in cloud
Towards secure and dependable storage service in cloudTowards secure and dependable storage service in cloud
Towards secure and dependable storage service in cloud
 
4 trigger
4  trigger4  trigger
4 trigger
 
Tair
TairTair
Tair
 
Ado.Net Architecture
Ado.Net ArchitectureAdo.Net Architecture
Ado.Net Architecture
 
Towards secure and dependable storage
Towards secure and dependable storageTowards secure and dependable storage
Towards secure and dependable storage
 
datastore_devfest2020_incheon
datastore_devfest2020_incheondatastore_devfest2020_incheon
datastore_devfest2020_incheon
 
Parameter substitution in Aginity Workbench
Parameter substitution in Aginity WorkbenchParameter substitution in Aginity Workbench
Parameter substitution in Aginity Workbench
 
Oracle performance tuning
Oracle performance tuningOracle performance tuning
Oracle performance tuning
 
Panda public auditing for shared data with efficient user revocation in the c...
Panda public auditing for shared data with efficient user revocation in the c...Panda public auditing for shared data with efficient user revocation in the c...
Panda public auditing for shared data with efficient user revocation in the c...
 

En vedette

En vedette (7)

OctHighlander
OctHighlanderOctHighlander
OctHighlander
 
JanuaryFebruary Highlander
JanuaryFebruary HighlanderJanuaryFebruary Highlander
JanuaryFebruary Highlander
 
Pro301 o week 2 assignment
Pro301 o week 2 assignmentPro301 o week 2 assignment
Pro301 o week 2 assignment
 
iOS training (intermediate)
iOS training (intermediate)iOS training (intermediate)
iOS training (intermediate)
 
Pro301 Week 5 Assignment
Pro301 Week 5 AssignmentPro301 Week 5 Assignment
Pro301 Week 5 Assignment
 
iOS App performance - Things to take care
iOS App performance - Things to take careiOS App performance - Things to take care
iOS App performance - Things to take care
 
Firefox addons
Firefox addonsFirefox addons
Firefox addons
 

Similaire à iOS Training (Advanced): Fetching Data from Server

High Availability And Oracle Data Guard 11g R2
High Availability And Oracle Data Guard 11g R2High Availability And Oracle Data Guard 11g R2
High Availability And Oracle Data Guard 11g R2Mario Redón Luz
 
Dataguard presentation
Dataguard presentationDataguard presentation
Dataguard presentationVimlendu Kumar
 
Asp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptxAsp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptxsridharu1981
 
Oracle Data Guard for Beginners
Oracle Data Guard for BeginnersOracle Data Guard for Beginners
Oracle Data Guard for BeginnersPini Dibask
 
IOUG Collaborate 18 - Data Guard for Beginners
IOUG Collaborate 18 - Data Guard for BeginnersIOUG Collaborate 18 - Data Guard for Beginners
IOUG Collaborate 18 - Data Guard for BeginnersPini Dibask
 
ASP.NET Session 11 12
ASP.NET Session 11 12ASP.NET Session 11 12
ASP.NET Session 11 12Sisir Ghosh
 
Oracle data guard for beginners
Oracle data guard for beginnersOracle data guard for beginners
Oracle data guard for beginnersPini Dibask
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08Vivek chan
 
Automated Testing with Databases
Automated Testing with DatabasesAutomated Testing with Databases
Automated Testing with Databaseselliando dias
 
Introduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptxIntroduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptxKnoldus Inc.
 
Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4than sare
 
File Repository on GAE
File Repository on GAEFile Repository on GAE
File Repository on GAElynneblue
 
Merging and Migrating: Data Portability from the Trenches
Merging and Migrating: Data Portability from the TrenchesMerging and Migrating: Data Portability from the Trenches
Merging and Migrating: Data Portability from the TrenchesAtlassian
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08Mani Chaubey
 

Similaire à iOS Training (Advanced): Fetching Data from Server (20)

High Availability And Oracle Data Guard 11g R2
High Availability And Oracle Data Guard 11g R2High Availability And Oracle Data Guard 11g R2
High Availability And Oracle Data Guard 11g R2
 
Dataguard presentation
Dataguard presentationDataguard presentation
Dataguard presentation
 
Asp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptxAsp .Net Database Connectivity Presentation.pptx
Asp .Net Database Connectivity Presentation.pptx
 
Oracle Data Guard for Beginners
Oracle Data Guard for BeginnersOracle Data Guard for Beginners
Oracle Data Guard for Beginners
 
IOUG Collaborate 18 - Data Guard for Beginners
IOUG Collaborate 18 - Data Guard for BeginnersIOUG Collaborate 18 - Data Guard for Beginners
IOUG Collaborate 18 - Data Guard for Beginners
 
ASP.NET Session 11 12
ASP.NET Session 11 12ASP.NET Session 11 12
ASP.NET Session 11 12
 
less08.ppt
less08.pptless08.ppt
less08.ppt
 
Oracle Data Guard
Oracle Data GuardOracle Data Guard
Oracle Data Guard
 
Oracle data guard for beginners
Oracle data guard for beginnersOracle data guard for beginners
Oracle data guard for beginners
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
 
Data Guard25 August
Data Guard25 AugustData Guard25 August
Data Guard25 August
 
Automated Testing with Databases
Automated Testing with DatabasesAutomated Testing with Databases
Automated Testing with Databases
 
Introduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptxIntroduction to GraphQL Presentation.pptx
Introduction to GraphQL Presentation.pptx
 
Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4
 
File Repository on GAE
File Repository on GAEFile Repository on GAE
File Repository on GAE
 
Merging and Migrating: Data Portability from the Trenches
Merging and Migrating: Data Portability from the TrenchesMerging and Migrating: Data Portability from the Trenches
Merging and Migrating: Data Portability from the Trenches
 
AfNetworking vs. Native + Caching
AfNetworking vs. Native + CachingAfNetworking vs. Native + Caching
AfNetworking vs. Native + Caching
 
Save data locally
Save data locallySave data locally
Save data locally
 
Ado.net
Ado.netAdo.net
Ado.net
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
 

Dernier

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 

Dernier (20)

ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 

iOS Training (Advanced): Fetching Data from Server

  • 1. iOS Training (Advanced) Gurpreet Singh Sriram Viswanathan Yahoo! Confidential 1
  • 2. Topics  Using custom delegate and protocols  Saving and Restoring the Application State  Introduction to NSURLConnection  Hands on example for  Fetching data from server  Using Table View Controller  Populating Data in a Table  Refreshing Data  Deploying your app on a device Yahoo! Confidential 2
  • 3. Using custom delegate and protocols Defining Protocol @protocol DataConsumerDelegate // Method to handle response of the rest connection call - (void) finishedReceivingData: (NSData *) data; @end Conforming to protocol @interface MyDataConsumer : NSObject <DataConsumerDelegate> @end @implementation MyDataConsumer - (void) finishedReceivingData: (NSData *) data { // HANDLE THE DATA } @end Yahoo! Confidential 3
  • 4. Using custom delegate and protocols Using delegate @interface AsynchronousRestConnection : NSObject { id<DataConsumerDelegate> dataConsumerDelegate; } // Used to store delgate object (it must conform to DataConsumerDelegateprotocol) @property (nonatomic, weak) id<DataConsumerDelegate> dataConsumerDelegate; - (void) getData; @end @implementation AsynchronousRestConnection @synthesize dataConsumerDelegate; - (void) getData { // GET DATA AND STORE IT IN data // YOU CAN DO MULTI QUERY AND MERGE OUTPUT [self.dataConsumerDelegate finishedReceivingData:data]; } @end Yahoo! Confidential 4
  • 5. Using custom delegate and protocols Updating the MyDataConsumer class to use AsynchronousRestConnection @interface MyDataConsumer : NSObject <DataConsumerDelegate> - (void) getDataFromApi; @end @implementation MyDataConsumer - (void) finishedReceivingData: (NSData *) data { // HANDLE THE DATA } - (void) getDataFromApi { AsynchronousRestConnection *arc = [[AsynchronousRestConnection alloc] init]; arc.dataConsumerDelegate = self; // CONSUME DATA } @end Yahoo! Confidential 5
  • 6. Topics  Using custom delegate and protocols  Saving and Restoring the Application State  Introduction to NSURLConnection  Hands on example for  Fetching data from server  Using Table View Controller  Populating Data in a Table  Refreshing Data  Deploying your app on a device Yahoo! Confidential 6
  • 7. Saving and Restoring Application State During the preservation and restoration process, your app has a handful of responsibilities. During preservation, your app is responsible for:  Telling UIKit that it supports state preservation.  Telling UIKit which view controllers and views should be preserved.  Encoding relevant data for any preserved objects. During restoration, your app is responsible for:  Telling UIKit that it supports state restoration.  Providing (or creating) the objects that are requested by UIKit.  Decoding the state of your preserved objects and using it to return the object to its previous state. Yahoo! Confidential 7
  • 8. Saving and Restoring Application State High-level flow interface preservation Yahoo! Confidential 8
  • 9. Saving and Restoring Application State High-level flow for restoring your user interface Yahoo! Confidential 9
  • 10. Topics  Using custom delegate and protocols  Saving and Restoring the Application State  Introduction to NSURLConnection  Hands on example for  Fetching data from server  Using Table View Controller  Populating Data in a Table  Refreshing Data  Deploying your app on a device Yahoo! Confidential 10
  • 11. Introduction to NSURLConnection  Asynchronous Request  Synchronous Request  POST request  Using Connection Timeout  Cache Policies Yahoo! Confidential 11
  • 12. Asynchronous Request To fetch some data, we’ll follow these 3 basic steps:  Have our class conform to the NSURLConnectionDelegate protocol and declare a var to store the response data  Implement the NSURLConnectionDelegate protocol methods  Create an instance of NSURLRequest and NSURLConnection to kick off the request Yahoo! Confidential 12
  • 16. Asynchronous Request Step 4:  First connection:didReceiveResponse will be hit, indicating that the server has responded.  Then the handler, connection:didReceiveData: will be hit several times.  This is where you’ll append the latest data to the response data variable you declared in Step 1.  Then finally, connectionDidFinishLoading: will be hit and you can parse the response data variable. Yahoo! Confidential 16
  • 17. POST Request A synchronous request looks like the below:  You’ll set the HTTPMethod property to POST  You’ll assign the header fields and value in the body  Ensure that you’re using an instance of NSMutableURLRequest because NSURLRequest is immutable. Yahoo! Confidential 17
  • 18. Using Connection Timeout Using Connection Timeout  If you want to set a timeout for your data retrieval, you can set the timeoutInterval property of your NSURLRequest.  Ensure that you’re using an instance of NSMutableURLRequest because NSURLRequest is immutable. Yahoo! Confidential 18
  • 19. Cache Policies To specify how your data should be cached locally, you can set a cache policy with your NSURLRequest. Following snippet shows you how you can define a cache policy and a timeout.  If you don’t specify any caching policy with your NSURLRequest, then it will try to conform to whatever the protocol states.  For example, with HTTP it will look at the server response headers and try to conform to what it dictates about caching. Yahoo! Confidential 19
  • 20. Topics  Using custom delegate and protocols  Saving and Restoring the Application State  Introduction to NSURLConnection  Hands on example for  Fetching data from server  Using Table View Controller  Populating Data in a Table  Refreshing Data  Deploying your app on a device Yahoo! Confidential 20
  • 21. Topics  Using custom delegate and protocols  Saving and Restoring the Application State  Introduction to NSURLConnection  Hands on example for  Fetching data from server  Using Table View Controller  Populating Data in a Table  Refreshing Data  Deploying your app on a device Yahoo! Confidential 21
  • 22. Deploying your app on a device Steps to deploy your app on a device Step 1: iOS Developer Program (iPhone provision portal) Step 2: Create a Certificate Signing Request Step 3: Create a Development Certificate Step 4: Adding a Device Step 5: Create an App ID Step 6: Create a Provisioning Profile Step 7: Configuring the Project Step 8: Build and Run For detail refer: http://mobile.tutsplus.com/tutorials/iphone/how-to-test-your-apps-on-physical-iosdevices/ Yahoo! Confidential 22

Notes de l'éditeur

  1. Another Reference:http://www.raywenderlich.com/8003/how-to-submit-your-app-to-apple-from-no-account-to-app-store-part-1