13.07.2015 Views

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

Beginning Objective-C pdf - EBook Free Download

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6Networking: Connections, Data,and the CloudIn today’s world of ubiquitous mobile devices and always-on connections to the Internet, thetopic of networking is of great importance. On iOS alone, a great quantity of applicationsmake use of the network in one way or the other, whether using built-in systems like iCloudsynchronization or GameKit’s communication framework, or by communicating directly withservers over the Internet. Moreover, the expectations of consumers often clashes with thecapabilities and limitations of wide-area mobile networks such as EDGE, 3G, and HDPSA+,leaving you, the application programmer, to make the best of a high-latency, low-throughputnetwork channel.Well, luckily for you, I have a positive ocean of information and experience to share onthis front. In this chapter you’ll learn about the URL loading system, and asynchronous,synchronous, and synthetic-synchronous network access. You’ll learn the best ways tohandle common types of data passed across the network and how to correctly handlebinary data in a system-agnostic fashion. You’ll also see how to locate services on thenetwork plus how you can create your own and make their information available in thesame manner.Perhaps most importantly, though, you’ll learn the rationale behind the following coretenets of network-centric programming on the Mac and iOS:• Never access the network from the main thread.• Use asynchronous network primitives wherever possible.• Use streams for all data handling.• Keep data handling and transport handling unaware of one another.Stick to these four rules and you’ll not go far wrong. In fact, you’ll be in a muchbetter position to handle anything the network can throw at you—because it will throweverything it can, sooner or later.159www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!