Beginning Swift
eBook - ePub

Beginning Swift

Master the fundamentals of programming in Swift 4

Rob Kerr, Kåre Morstøl

Compartir libro
  1. 196 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Beginning Swift

Master the fundamentals of programming in Swift 4

Rob Kerr, Kåre Morstøl

Detalles del libro
Vista previa del libro
Índice
Citas

Información del libro

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.

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Beginning Swift un PDF/ePUB en línea?
Sí, puedes acceder a Beginning Swift de Rob Kerr, Kåre Morstøl en formato PDF o ePUB, así como a otros libros populares de Informatica y Programmazione. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2018
ISBN
9781789538649
Edición
1
Categoría
Informatica
Categoría
Programmazione

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...

Índice