Example iOS Apphttp://github.com/joe-goullaud/Github-iOS
Don’t forget to grab the submodules:$> git submodule update --init --recursive
Overview
• How to Leverage Web Services in Your App
• iOS Patterns Overview
• Example App
• Mobile API Best Practices
Leveraging Web Services
Leveraging Web Services
• Content
• Images
• Video
• Documents
• Communication
• Text
• Voice
• Video
• Synchronization
• Game Play
• Document Collaboration
• Data
• Sharing
iOS Client Applications
• Common Patterns
• MVC(S) - Model-View-Controller-(Store)
• Delegation
• Callback/Completion Blocks (Closures)
UIViewController
UIViewModel
Store
UIViewController UITableView
tableView:cellForRowAtIndexPath:
UITableViewCell
tableView:heightForRowAtIndexPath:
44
tableView:didSelectRowAtIndexPath:
Main Thread Background Thread
Network Request
Data Import
Network Completion
Import Completion
Update UI
User Action
DEMO
Mobile API Best Practices
Mobile API Goals
• Reduce Network Calls
• Small Responses with Just Enough Data
• Secure
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
JSON
• Compact
• Low memory footprint
• 2x faster to parse than XML
• Easier to create on device
• Smaller Request Bodies
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
Security
• HTTPS
• No secure data in URL Query
• OAuth 2
• Token-based
• Authorization Headers
• HMAC for request authentication
Recommended