Transcript
Page 1: Building Client-Server Apps for iOS

Building Client/Server Applications for iOS

Joe [email protected]

ADN/Twitter: @jgoullaud

Page 2: Building Client-Server Apps for iOS

Example iOS Apphttp://github.com/joe-goullaud/Github-iOS

Don’t forget to grab the submodules:$> git submodule update --init --recursive

Page 3: Building Client-Server Apps for iOS

Overview

• How to Leverage Web Services in Your App

• iOS Patterns Overview

• Example App

• Mobile API Best Practices

Page 4: Building Client-Server Apps for iOS

Leveraging Web Services

Page 5: Building Client-Server Apps for iOS

Leveraging Web Services

• Content

• Images

• Video

• Documents

• Communication

• Text

• Voice

• Video

• Synchronization

• Game Play

• Document Collaboration

• Data

• Sharing

• Facebook

• Twitter

Page 6: Building Client-Server Apps for iOS

iOS Client Applications

• Common Patterns

• MVC(S) - Model-View-Controller-(Store)

• Delegation

• Callback/Completion Blocks (Closures)

Page 7: Building Client-Server Apps for iOS

UIViewController

UIViewModel

Store

Page 8: Building Client-Server Apps for iOS

UIViewController UITableView

tableView:cellForRowAtIndexPath:

UITableViewCell

tableView:heightForRowAtIndexPath:

44

tableView:didSelectRowAtIndexPath:

Page 9: Building Client-Server Apps for iOS

Main Thread Background Thread

Network Request

Data Import

Network Completion

Import Completion

Update UI

User Action

Page 10: Building Client-Server Apps for iOS

DEMO

Page 11: Building Client-Server Apps for iOS

Mobile API Best Practices

Page 12: Building Client-Server Apps for iOS

Mobile API Goals

• Reduce Network Calls

• Small Responses with Just Enough Data

• Secure

Page 13: Building Client-Server Apps for iOS

Caching

• Cache-Control Headers

• Set no-cache and max-age as appropriate

• Set to no-cache on Errors

• Images

• GET and HEAD request headers

• Content-Length

• Content-Type

• Last-Modified

Page 14: Building Client-Server Apps for iOS

JSON

• Compact

• Low memory footprint

• 2x faster to parse than XML

• Easier to create on device

• Smaller Request Bodies

Page 15: Building Client-Server Apps for iOS

REST-like

• Resource Endpoints

• Plural Endpoints should return object summaries

• Single Resource Endpoints return full object

• Can return object summaries of related objects

• Action Endpoints

• Perform complex service actions atomically

Page 16: Building Client-Server Apps for iOS

Security

• HTTPS

• No secure data in URL Query

• OAuth 2

• Token-based

• Authorization Headers

• HMAC for request authentication

Page 17: Building Client-Server Apps for iOS

Questions?

Joe [email protected]

ADN/Twitter: @jgoullaud

Page 18: Building Client-Server Apps for iOS