Minimum price
Suggested price


About the Book



SWIFT is object oriented programming language for building applications for OSX and iOS operating systems.

SWIFT home page is at https://developer.apple.com/swift/.


Book content

This book is collection of standalone tutorials.

This means that each tutorial contains minimum amount of code needed to explain specific functionality.

This is in contrast to building a single application where each new functionality is added on top of already explained ones.

Each tutorial has minimum amount of supporting text making emphasis on the code example to do the explaining.


How to use this book

This book can be used as an introduction to SWIFT language covering all of the basic core functionalities.

In addition book will be updated with more tutorials covering more specific subjects.

Book is also intended as Just In Time Support so that user can learn what it needs when it needs it.

This is why tutorials are standalone and minimalistic focusing only at one problem at the time.

You should however first go through the main features of SWIFT to familiarize yourself with the core concepts.

This can be done by first going through the main chapters as deep as you see fit.

Then later you can come back to explore other more specific chapters as you need them.

About the Author

Ivor Online
Ivor Online


"Things are only as complicated as they are badly explained" 

Proper documentation is essential to avoid struggle and frustration when working with simple things that only seem complicated by not being properly documented and explained. 



"Working example is worth thousand words"

Just like the picture is worth thousand words the same goes for the working example. Documentation in the form of working examples is proved to be the fastest and the most effective way of transferring knowledge. Sometimes an example is all you need to get the things done. And if there are some accompanying comments that explain what is going on even better. This approach is used in this book. This results in fast learning and the ability to apply tutorials when you need them in the spirit of Just In Time Support. 

I wish you rapid learning!




Table of Contents

1. Introduction

1.1      Create SWIFT Application

1.1.1        Using online compiler

2. Predefined data types and their literals

2.1      Predefined data types

2.1.1        Scalar         Nil         Bool         Int         UInt         Float         Double         String

2.1.2        Collection         Set         Dictionary         Array

2.2      Literals

2.2.1        Nil

2.2.2        Boolean

2.2.3        Integer         Decimal Notation         Binary Notation         Octal Notation         Hexadecimal Notation

2.2.4        Float         Basic Notation         Scientific Notation

2.2.5        String

2.2.6        Array

3. Constants, Variables and Optionals

3.1      Constants

3.1.1        Declare         Name         Data type

3.2      Stored Variables

3.2.1        Declare         Name         Data type

3.3      Computed Variables

3.3.1        Declare         Getter         Setter

3.4      Optionals

3.4.1        Declare         Name         Data type         Forced unwrapping         Optional binding

3.5      Computed Optionals

3.5.1        Declare         Getter         Setter

4. Basic syntax


4.1.1        Single Line

4.1.2        Multi Line

4.2      Operators

4.2.1        Comparison

4.2.2        Arithmetic

4.2.3        Assignment

4.2.4        Bitwise

4.2.5        Logical

4.3      Statements

4.3.1        Conditional         Branching      if      if case      else if      else if case      else      switch...case      ? :         Looping      for      for…in      while      do...while

4.3.2        Jumping         break         continue         return

4.4      Errors

4.4.1        assert

4.4.2        guard

4.4.3        do...catch

4.5      Type aliases

4.5.1        Declare

4.6      Observers

4.6.1        Declare

4.7      Closures

4.7.1        Declare

5. Creating custom data types

5.1      Classes

5.1.1        Declare data type

5.1.2        Designated Initializer

5.1.3        Convenience Initializer

5.1.4        Deinitializer

5.1.5        Inherit Class

5.1.6        Conform to protocol

5.2      Structures

5.2.1        Declare data type

5.2.2        Initializer

5.2.3        Mutating methods

5.2.4        Conform to protocol

5.3      Enumerators

5.3.1        Simple Enumerator         Declare Data Type of Values      Int      Float      String         Initializer         Reference

5.3.2        Complex Enumerator         Declare type         Reference         Initializer         Extract data

5.4      Protocols

5.4.1        Declare data type         Property         Method

5.5      Functions

5.5.1        Declare

5.5.2        Reference

5.5.3        Name

5.5.4        Scope         Global         Function

5.5.5        Return         Number of values      None      Single      Multiple         Types      Scalar      Tuple      Function

5.5.6        Parameters         Default values         Number of parameters      Zero      One      Multiple      Variable         Names      No public names declared      Public names declared      Public names omitted         Modifiers      Variadic      Constant      Variable      In-Out         Types      Scalar      Tuple      Function      Closure

5.6      Tuples

5.6.1        Declare

5.6.2        Reference

6. Advanced topics

6.1      Properties

6.1.1        Declare

6.1.2        Reference         Static field from static method         Static field from instance method         Static field using class name         Instance field from instance method         Instance field from object         Field using self         Parent's fields

6.1.3        Scope Modifiers         Public         Internal         Private

6.1.4        Other Modifiers         Static

6.2      Methods

6.2.1        Declare

6.2.2        Reference         Static method from static method         Static method from instance method         Static method using class name         Instance method from instance method         Instance method from object         Method using self         Parent's methods

6.2.3        Scope Modifiers         Public         Internal         Private

6.2.4        Other Modifiers         Static         Final

6.2.5        Predefined

6.2.6        Override

6.3      Extensions

6.3.1        Declare

6.3.2        Add         Method         Computed property         Convenience initializer

6.4      Subscripts

6.4.1        Declare

6.5      Generics

6.5.1        Class         Declare         Extend

6.5.2        Structure         Declare         Extend

6.5.3        Enumerator         Declare

6.5.4        Function         Declare

6.5.5        Constraints         Conform to existing protocol         Conform to custom protocol

6.6      Custom Operators

6.6.1        Prefix

6.6.2        Postfix

6.6.3        Infix

6.7      Patterns

6.7.1        Wildcard

6.7.2        Identifier

6.7.3        Value-Binding

6.7.4        Tuple

6.7.5        Enumeration Case

7. Tools

7.1      Online compiler

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub