If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Preface
Swift is a multi-paradigm language. It has expressive features familiar to those used to working with modern functional languages, whilst also keeping the object-oriented features of Objective-C. Swift vastly streamlines the developer experience, and Apple's Xcode playground is a real game-changer.
The book begins by teaching you the basic syntax and structure of Swift, and how to correctly structure and architect software using Swift. It then builds expertise in the core Swift standard library you will need to understand to complete real-world Swift programming projects. We will work through concepts such as operators, branching and loop structures, functions, classes, structs, collections, and strings. We end the book with a brief look at functional programming and lazy operations.
After reading and understanding this book, you will be well-prepared to begin developing native end-user applications for iOS or macOS, or to develop server-side (backend) application and web services using Swift on Linux.
What This Book Covers
, Swift Basics , covers the fundamentals of using the Swift programming language. In this lesson, you'll learn basic Swift syntax and program structure. You'll also learn how to use Swift built-in data types and enums, and how to declare and use Swift variables and constants.
, Swift Operators and Control Flow , shows you how to use the fundamental flow control structures and language elements that form the building blocks of Swift programs. We will specifically cover operators, branching statements, and loops in this lesson.
, Functions, Classes, and Structs , teaches you how to develop fully featured Swift functions, catch unexpected errors, and use asynchronous programming paradigms. You'll learn how to create your own data types, and create object-oriented applications using classes and structs.
, Collections , shows you how to work with Swift's collections, such as arrays, sets, and dictionaries.
, Strings , covers Swift strings in detail. We will create and use strings and substrings, and see the various common operations available for strings.
, Functional Programming and Lazy Operations , ventures at functional programming and explains what lazy operations are. We will end this lesson with an important but often overlooked topicwriting Swifty code.
What You Need for This Book
This book will require the following hardware:
- A Mac computer capable of running macOS Sierra 10.12.6+
- An internet connection
Please ensure you have the following software installed on your machine:
- Operating system: macOS Sierra 10.12.6+
- Xcode 9.1
- Safari browser
Who This Book is for
This book is ideal for developers seeking fundamental Swift programming skills, in preparation for learning to develop native applications for iOS or macOS. No prior Swift knowledge is expected but object-oriented programming experience is desirable.
You should have basic working knowledge of computer programming in a procedural/object-oriented language, such as Objective-C, BASIC, C++, Python, Java, or JavaScript.
Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text are shown as follows: "Finally, use the console print
function to output the content of each error variable."
Folder names, filenames, file extensions, pathnames, include file names in text are shown as follows: "Launch Xcode as before, and create a new playground named Create a Variable.playground