Beginning Swift
eBook - ePub

Beginning Swift

Master the fundamentals of programming in Swift 4

Rob Kerr, Kåre Morstøl

Buch teilen
  1. 196 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Beginning Swift

Master the fundamentals of programming in Swift 4

Rob Kerr, Kåre Morstøl

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Swift greatly simplifies the process of developing applications for Apple devices. This book provides you with the essential skills to help you get started with developing applications using Swift.

Key Features

  • Teaches you how to correctly structure and architect software using Swift
  • Uses real-world examples to connect the theory to a professional setting
  • Imparts expertise in the core Swift standard library

Book Description

Take your first foray into programming for Apple devices with Swift.Swift is fundamentally different from Objective-C, as it is a protocol-oriented language. While you can still write normal object-oriented code in Swift, it requires a new way of thinking to take advantage of its powerful features and a solid understanding of the basics to become productive.

What you will learn

  • Explore the fundamental Swift programming concepts, language structure, and the Swift programming syntax
  • Learn how Swift compares to other computer languages and how to transform your thinking to leverage new concepts such as optionals and protocols
  • Master how to use key language elements, such as strings and collections
  • Grasp how Swift supports modern application development using advanced features, such as built-in Unicode support and higher-order functions

Who this book is for

If you are seeking fundamental Swift programming skills, in preparation for learning to develop native applications for iOS or macOS, this book is the best for you. You don't need to have any prior Swift knowledge; however, object-oriented programming experience is desired.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Beginning Swift als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Beginning Swift von Rob Kerr, Kåre Morstøl im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Informatica & Programmazione. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2018
ISBN
9781789538649

Beginning Swift


Table of Contents

Beginning Swift
Why Subscribe?
PacktPub.com
Contributors
About the Authors
Packt is Searching for Authors Like You
Preface
What This Book Covers
What You Need for This Book
Who This Book is for
Conventions
Reader Feedback
Customer Support
Downloading the Example Code
Errata
Piracy
Questions
1. Swift Basics
Lesson objectives
Swift Program Structure
Hello, World!
Swift Variables and Constants
Declaring Swift Variables
Variables Versus Constants
Type Inference
Variable Naming
Working with Variables
Tuples
Creating a Tuple
Optionals
Declaring an Optional
Working with Optionals
Optional nil Values
Accessing Optional Values
Force Unwrapping an Optional
Conditionally Unwrapping Optionals
Using Optionals
The Swift guard Statement
Activity: Variable Summary
Swift Data Types
Numeric Data Types
Int on 64-Bit Versus 32-Bit Platforms
Built-In Numeric Data Types
Choosing the Appropriate Numeric Data Type
Declaring and Assigning Integer Variables
Declaring and Assigning Floating Point Numbers
Numeric Literal Grouping
Numeric Type Conversions
Using Numeric Types
Boolean
Character
Assigning a Character
Constructing a Character Literal
String
Instantiating a String
String Concatenation
Extracting Characters
String Length
Activity: Data Type Summary
Enums
Basic Enum Syntax
Enum with Raw Values
Activity: Using Swift Enums
Summary
2. Swift Operators and Control Flow
Lesson objectives
Swift Operators
Assignment Operator
Arithmetic Operators
Standard Arithmetic Operators
Remainder Operator
Unary minus Operator
Compound Assignment Operators
Comparison Operators
Equality
Inequality
Comparison between Two Values
Ternary Conditional Operator
Logical Operators
Bitwise Operators
Nil-Coalescing Operator
Range Operators
Closed Range Operator
Half-Open Range Operator
One-Sided Range Operator
Activity: Operators
Branching
The if Statement
Condition Lists
Optional Unwrapping with if
The switch Statement
switch Statement Rules
The break Keyword
The fallthrough Keyword
Matching Non-Scalar Values
Multiple Patterns in a Single Case
Using the where Statement within case
Evaluating Optionals with a switch Statement
Activity: Converting Code from if to switch
Loops
The for…in Statement
Iterating over Objects
Iterating over Array Objects with index
The for Loop where Clause
The break Control Transfer Statement
The continue Control Transfer Statement
The while Loop
The repeat…while Loop
Activity: Implementing Loops
Summary
3. Functions, Classes, and Structs
Lesson Objectives
Functions
Defining a Function
Argument Labels
Excluding Argument Labels
Parameter Default Values
Activity: Implementing a Function
Returning Values from Functions
Using @discardableResult
Function Attributes
Variadic Parameters
inout Parameters
Recursion
Functions as Parameters
Closures
Creating a Function to Receive Content from an Asynchronous Web Service Call
Error Handling
The do…catch Statement
Multiple catch Blocks
Using do without catch
The guard Statement
Activity: Exception Handling
Object-Oriented Features
Object-Oriented Principles
Classes Versus Structs
Illustration
Defining Classes and Structures
Activity: Creating a Customer Struct and Class
Summary
Challenge
4. Collections
Lesson Objectives
Arrays
Working with Arrays
Index
Common Operations with Index
ArraySlice
Creating Slices
Activity: Working with Arrays
Sets
Working with Sets
Combining Sets
Comparing Sets
Activity: Removing Duplicates from a Sequence
Dictionaries
Working with Dictionaries
Activity: Using Dictionaries
Summary
5. Strings
Lesson Objectives
String Fundamentals
Character
Collection
Index
Working with String Index
Debugging
Activity: All Indices of a Character
Using Strings
Creating Strings
Common Operations
Activity: All Ranges of a Substring
Activity: Counting Words, Sentences, and Paragraphs
Substring
Creating Substrings
Parsing Strings
Converting NSRange to Range
Activity: CamelCase
Summary
6. Functional Programming and Lazy Operations
Lesson Objectives
Function Type
Functional Methods
filter
Using the filter Method
map
Using the map Method
flatMap
Using the flatMap Method
reduce
Using the reduce Function
Activity: Using Functional Programming
Lazy Operations
Lazy Sequences
Sequence Internals
Creating Lazy Operations
sequence(first:next:)
sequence(state:next:)
Activity: Implementing a Lazy Version of a Method
Swifty Code
Naming
Organizing Code
Miscellaneous
Writing Swifty Code
Summary
Further Study
Challenge
Index

Beginning Swift

Copyright © 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accurac...

Inhaltsverzeichnis