iOS training (advanced)
Upcoming SlideShare
Loading in...5
×
 

iOS training (advanced)

on

  • 160 views

 

Statistics

Views

Total Views
160
Views on SlideShare
160
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Another Reference:http://www.raywenderlich.com/8003/how-to-submit-your-app-to-apple-from-no-account-to-app-store-part-1

iOS training (advanced) iOS training (advanced) Presentation Transcript

  • 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 View slide
  • 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 View slide
  • 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