Skip to Content
Programming iOS 10
book

Programming iOS 10

by Matt Neuburg
November 2016
Beginner to intermediate content levelBeginner to intermediate
800 pages
30h 12m
English
O'Reilly Media, Inc.
Content preview from Programming iOS 10

Chapter 23. Basic Networking

Networking is difficult and complicated, chiefly because it’s ultimately out of your control. You can ask for a resource from across the network, but at that point anything can happen: the resource might not be found, it might take a while to arrive, it might never arrive, the server might be down, the server or the network itself might vanish after the resource has partially arrived. iOS, however, makes at least the basics of networking very easy, so that’s what this chapter will deal with.

To go further into networking than this chapter takes you, start with Apple’s URL Session Programming Guide. To go even deeper under the hood, see the CFNetwork Programming Guide. Apple also provides a generous amount of sample code.

Many earlier chapters have described interface and frameworks that network for you automatically. Put a web view in your interface (Chapter 11) and poof, you’re networking; the web view does all the grunt work, and it does it a lot better than you’d be likely to do it from scratch. The same is true of AVPlayer (Chapter 15), MKMapView (Chapter 20), and so on.

Starting in iOS 9, App Transport Security is enforced, meaning that HTTP requests must be HTTPS requests and that the server must be using TLS 1.2 or higher. To tweak the behavior of App Transport Security, you must make an entry in your app’s Info.plist, in the “App Transport Security Settings” dictionary (NSAppTransportSecurity). For example, to allow HTTP requests in general, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming iOS 12

Programming iOS 12

Matt Neuburg
Programming iOS 11

Programming iOS 11

Matt Neuburg
Programming iOS 13

Programming iOS 13

Matt Neuburg

Publisher Resources

ISBN: 9781491970157Errata Page