Book Image

Swift Essentials - Second Edition

By : Alex Blewitt
Book Image

Swift Essentials - Second Edition

By: Alex Blewitt

Overview of this book

Swift was considered one of the biggest innovations last year, and certainly with Swift 2 announced at WWDC in 2015, this segment of the developer space will continue to be hot and dominating. This is a fast-paced guide to provide an overview of Swift programming and then walks you through in detail how to write iOS applications. Progress through chapters on custom views, networking, parsing and build a complete application as a Git repository, all by using Swift as the core language
Table of Contents (17 chapters)
Swift Essentials Second Edition
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Index

Direct network connections


Although most application networking will involve downloading content over standard protocols, such as HTTP(S), and using standard representations, there are times when having a specific data stream protocol is required. In this case, a stream-oriented process will allow individual bytes to be read or written, or a datagram or packet-oriented process can be used to send individual packets of data.

There are networking libraries to support both; an NSStream higher-level Objective-C based class provides a mechanism to drive stream-based responses, and although lower-level packet connections are possible with the CoreFoundation or the POSIX layer, local multiplayer gaming using the MultipeerConnectivity module is often appropriate.

Note

Local networking with the MultipeerConnectivity module involves creating an MCSession, followed by sendData to send NSData objects to connected peers, and using the MCSessionDelegate to receiveData from connected peers. This is often...