Learning Swift
上QQ阅读APP看书,第一时间看更新

Preface

This book will help you get started with Swift in no time. It will help you to understand the nuances of iOS programming not only from a conceptual point of view, but also from an implementation perspective. This book is an invaluable resource if you are looking forward to a pe deep into the world of iOS application programming.

What this book covers

Chapter 1, Introducing Swift, takes you through the process of installing Swift and running your first Swift program to expose its power right away.

Chapter 2, Building Blocks – Variables, Collections, and Flow Control, introduces you to the various built-in mechanisms Swift has to represent complex information in expressive and accessible ways with the help of a real-world example.

Chapter 3, One Piece at a Time – Types, Scopes, and Projects, introduces the tools necessary to more closely model the real world with code. It will teach you to define your own custom types using structures, classes, and enumerations. It also explores the concept of scope and access control.

Chapter 4, To Be or Not to Be – Optionals, focuses on a special and critical type in Swift called optionals. It includes a detailed explanation of how optionals work and how they can be used to turn a seemingly complex topic into a very intuitive concept.

Chapter 5, A Modern Paradigm – Closures and Functional Programming, introduces you to a new way of thinking about code called functional programming. We learn how Swift supports this technique and how we can apply it to our programs to make them even more understandable and expressive code.

Chapter 6, Make Swift Work for You – Protocols and Generics, describes what generic protocols are and how they can provide power and safety at the same time.

Chapter 7, Everything is Connected – Memory Management, discusses how a computer stores information and how we can use that knowledge in combination with some new tools in Swift, to ensure that our code remains responsive and minimizes its effect on battery life. In this chapter, we pe deeper into the inner workings of Swift.

Chapter 8, Writing Code the Swift Way – Design Patterns and Techniques, introduces you to the art of programming by taking you through a number of specific design patterns that help reduce the complexity of code.

Chapter 9, Harnessing the Past – Understanding and Translating Objective-C, develops a basic understanding of Objective-C with a focus on how it compares to Swift. This allows you to make use of the vast resources that exist in Objective-C to help with your Swift development.

Chapter 10, A Whole New World – Developing an App, explains the process of creating a real-world iOS application with the help of an example.

Chapter 11, What's Next? Resources, Advice, and Next Steps, discusses how to move forward to become the best app developer you possibly can. It will also provide you with a list of resources you can use to continue your Swift and app development learning process.

What you need for this book

The only thing that you need for this book is Xcode 6.3.

Who this book is for

If you are looking to build iOS or OS X apps using the most modern technology, this book is ideal for you. Learning Swift will place you in a small developer community that will explode in demand as the development of apps for Apple's platforms transitions to it. You will find this book especially useful if you are new to programming or if you are yet to develop an app for iOS or OS X.

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, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "It stores the text "Something Else" into a new variable called str."

A block of code is set as follows:

if invitees.count > 20 {
   println("Too many people invited")
}
else if invitees.count <= 3 {
    println("Not really a party")
}
else {
    println("Just right")
}

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "To view the console, you can go to View | Assistant Editor | Assistant Editor."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.