Chapter 6. Getting metadata for barcodes

 

This chapter covers

  • Modern networking with NSURLSession
  • Updating Core Data databases asynchronously
  • Presenting a barcode scanner modally, and using unwind segues
  • Calling RESTful web services
  • Unit testing web service wrappers

When you scan a barcode on a product, you end up with a GTIN (Global Trade Item Number). As an engineer, you might be marveling at the beauty of those digits, but your users will want more interesting benefits from having scanned the bars.

A traditional point-of-sale (POS) system has a local database mapping GTINs to products and their prices. But having a mobile barcode scanner in your pocket and the ability to retrieve product metadata over the internet gives you a leg up on POS. Having barcode scanning and internet connectivity together in a mobile device enables a new breed of apps that can be as niche-specific as they are product-centric.

When Apple introduced iOS 7, they gave networking a major overhaul by introducing NSURLSession. Prior to that, you had to create and configure requests individually, and you only had a global cache to work with. URL sessions take on most of the configuring work and have their own session-local caching. As an added bonus, you can perform downloads outside of your app (a.k.a. “out-of-process”) with an iOS background downloading daemon.

6.1. Modern networking with NSURLSession

 
 

6.2. Unit-testing network operations

 

6.3. Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest