Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Meetup uikit programming

7,253 views

Published on

  • Be the first to comment

  • Be the first to like this

Meetup uikit programming

  1. 1. <ul><li>João Prado Maia </li></ul><ul><li>Ipanema Labs, LLC </li></ul><ul><li>http://ipanemalabs.com </li></ul>UIKit Programming (and some network stuff too)
  2. 2. Who? <ul><li>Web programmer by day, iOS developer by night. </li></ul><ul><li>Consultant on iOS development projects. Contact me at http://ipanemalabs.com </li></ul><ul><li>Few apps on App Store since 2008. </li></ul><ul><li>Personal site at http://pessoal.org </li></ul>
  3. 3. Tonight’s session <ul><li>Hands on </li></ul><ul><li>Lots of code to go through </li></ul><ul><li>Ask questions at any time! </li></ul>
  4. 4. Table views <ul><li>Standard classes: </li></ul><ul><ul><li>UINavigationController </li></ul></ul><ul><ul><li>UIViewController </li></ul></ul><ul><ul><li>UITableViewController </li></ul></ul><ul><li>Goal: build a simple app with a drill down interface. </li></ul>
  5. 5. Saving data to SQLite <ul><li>FMDB! </li></ul><ul><ul><li>http://code.google.com/p/flycode/source/browse/trunk/fmdb </li></ul></ul><ul><ul><li>Open source wrapper on top of SQLite. </li></ul></ul><ul><ul><li>Actively maintained; easy to work with. </li></ul></ul><ul><li>Goal: change previous example to load information from a SQLite database. </li></ul>
  6. 6. Dealing with an API <ul><li>ASIHTTPRequest </li></ul><ul><ul><li>http://allseeing-i.com/ASIHTTPRequest/ </li></ul></ul><ul><ul><li>Much more convenient than NSURLConnection. </li></ul></ul><ul><ul><li>Open source; very easy to use. </li></ul></ul><ul><li>Goal: modify previous example to load data from an API dynamically. </li></ul>
  7. 7. ASIHTTPRequest <ul><li>Advanced features available to you in an easy to use wrapper: </li></ul><ul><ul><li>Download data to memory or directly to file </li></ul></ul><ul><ul><li>Easy to upload files through POST </li></ul></ul><ul><ul><li>Automatic progress indicators for downloads/uploads </li></ul></ul><ul><ul><li>Asynchronous/Synchronous requests and persistent connections </li></ul></ul><ul><ul><li>etc </li></ul></ul><ul><li>Good documentation with lots of examples </li></ul>
  8. 8. ASIHTTPRequest (2) - (IBAction)grabURL:(id)sender { NSURL *url = [NSURL URLWithString:@&quot;http://allseeing-i.com&quot;]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request startSynchronous]; NSError *error = [request error]; if (!error) { NSString *response = [request responseString]; } }
  9. 9. ASIHTTPRequest (3) - (IBAction)grabURLInBackground:(id)sender { NSURL *url = [NSURL URLWithString:@&quot;http://allseeing-i.com&quot;]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self]; [request startAsynchronous]; } - (void)requestFinished:(ASIHTTPRequest *)request { // Use when fetching text data NSString *responseString = [request responseString]; // Use when fetching binary data NSData *responseData = [request responseData]; } - (void)requestFailed:(ASIHTTPRequest *)request { NSError *error = [request error]; }
  10. 10. JSON <ul><li>JSON - JavaScript Object Notation </li></ul><ul><ul><li>Serialization format much less verbose than XML </li></ul></ul><ul><ul><li>Perfect for web services that need to return information for mobile clients </li></ul></ul><ul><li>iOS library: json-framework </li></ul><ul><ul><li>http://code.google.com/p/json-framework/ </li></ul></ul><ul><ul><li>Open source (BSD) library </li></ul></ul>
  11. 11. JSON (2) <ul><li>Serialized hash/dictionary: </li></ul><ul><li>{“key1”: “value1”, “key2”: “value2”} </li></ul><ul><li>Serialized array: </li></ul><ul><li>[“value1”, “value2”, “value3”] </li></ul><ul><li>Mixed object (array of dictionaries): </li></ul><ul><li>[{“name”: “Joao”, “ssn”:”12345678”}, {“name”:”Barry”, “ssn”:”98765432”}] </li></ul>
  12. 12. JSON parsing example NSArray *list; NSString *jsonString = @&quot;[&quot;Meetup&quot;, &quot;is&quot;, &quot;cool&quot;]&quot;; list = [jsonString JSONValue]; NSLog(@&quot;first entry: %@&quot;, [list objectAtIndex:0]); NSLog(@&quot;second entry: %@&quot;, [list objectAtIndex:1]); NSLog(@&quot;third entry: %@&quot;, [list objectAtIndex:2]); [json release];
  13. 13. Q&A <ul><li>Any questions? </li></ul>

×