万本电子书0元读

万本电子书0元读

顶部广告

Mastering Swift 3 - Linux电子书

售       价:¥

4人正在读 | 0人评论 9.8

作       者:Jon Hoffman

出  版  社:Packt Publishing

出版时间:2017-01-01

字       数:334.7万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Learn to build fast and robust applications on the Linux platform with Swift About This Book Create robust applications by building a strong foundation in the Swift Language Utilize Swift 3 on the embedded Linux platform for IoT and Robotic projects Build more flexible and high-performing applications on desktop, server, and embedded Linux platforms Who This Book Is For This book is for Linux developers who are interested in quickly learning how to use Swift to create exciting applications on Linux platforms. What You Will Learn Install Swift on the Linux platform Explore the power of the Swift language Get to know the proper design techniques Understand Swift’s new Core Library Implement popular design patterns with Swift Integrate C libraries with Swift Using Swift on Single-Board Computers Learn how to add concurrency to your application with Grand Central Dispatch Learn how to work with Swift Generics Learn how to use the Protocol-Oriented design paradigm In Detail Swift is a modern, fast, and safe programming language created by Apple. Writing Swift is interactive and fun, the syntax is concise yet expressive, and the code runs lightning-fast. Swift’s move to open source has been embraced with open arms and has seen increased adoption in the Linux platform. Our book will introduce you to the Swift language, further delving into all the key concepts you need to create applications for desktop, server, and embedded Linux platforms. We will teach you the best practices to design an application with Swift 3 via design patterns and Protocol-Oriented Programming. Further on, you will learn how to catch and respond to errors within your application. When you have gained a strong knowledge of using Swift in Linux, we’ll show you how to build IoT and robotic projects using Swift on single board computers. By the end of the book, you will have a solid understanding of the Swift Language with Linux and will be able to create your own applications with ease. Style and approach This easy-to-follow, code-rich guide is filled with examples that demonstrate how to put the concepts into practice. You’ll also get design patterns and best practices to get you writing better applications on the Linux platform.
目录展开

Mastering Swift 3 - Linux

Mastering Swift 3 - Linux

Credits

About the Author

About the Reviewers

www.PacktPub.com

Why subscribe?

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

Downloading the color images of this book

Errata

Piracy

Questions

1. Taking the First Steps with Swift

What is Swift?

Swift's features

Installing Swift 3 for Linux

Swift language syntax

Comments

Semicolons

Parentheses

Curly brackets

Assignment operators do not return a value

Spaces are optional in conditional and assignment statements

Hello World

Executing Swift code

Swift and the Swift REPL

Swift compiler

Using the Swift Package Manger

Editors for Swift

Summary

2. Learning About Variables, Constants, Strings, and Operators

Constants and variables

Defining constants and variables

Type safety

Type inference

Explicit types

Numeric types

Integers

Floating point

The Boolean type

The String type

Optional variables

Enumerations

Operators

The assignment operator

Comparison operators

Arithmetic operators

The remainder operator

Compound assignment operators

The ternary conditional operator

The logical NOT operator

The logical AND operator

The logical OR operator

Summary

3. Using Swift Collections and the Tuple Type

Swift collection types

Mutability

Arrays

Creating and initializing arrays

Accessing the array elements

Counting the elements of an array

Is the array empty?

Appending to an array

Inserting a value into an array

Replacing elements in an array

Removing elements from an array

Adding two arrays

Reversing an array

Retrieving a subarray from an array

Making bulk changes to an array

Algorithms for arrays

Sort

Sorted

Filter

Map

forEach

Iterating over an array

Dictionaries

Creating and initializing dictionaries

Accessing dictionary values

Counting key or values in a dictionary

Is the dictionary empty?

Updating the value of a key

Adding a key-value pair

Removing a key-value pair

Set

Initializing a set

Inserting items into a set

The number of items in a set

Checking whether a set contains an item

Iterating over a set

Removing items in a set

Set operations

Tuples

Summary

4. Control Flow and Functions

What we have learned so far

Curly brackets

Parentheses

Control flow

Conditional statements

The if statement

Conditional code execution with the if...else statement

The for loop

Using the for...in loop

The while loop

Using the while loop

Using the repeat...while loop

The switch statement

Using case and where statements with conditional statements

Filtering with the where statement

Filtering with the for…case statement

Using the if...case statement

Control transfer statements

The continue statement

The break statement

The fallthrough statement

The guard statement

Functions

Using a single-parameter function

Using a multi-parameter function

Defining a parameter's default values

Returning multiple values from a function

Returning optional values

Adding external parameter names

Using variadic parameters

Inout parameters

Nesting functions

Putting it all together

Summary

5. Classes and Structures

What are classes and structures?

Similarities between classes and structures

Differences between classes and structures

Value versus reference types

Creating a class or structure

Properties

Stored properties

Computed properties

Property observers

Methods

Custom initializers

Internal and external parameter names

Failable initializers

Inheritance

Overriding methods and properties

Overriding methods

Overriding properties

Preventing overrides

Protocols

Protocol syntax

Property requirements

Method requirements

Extensions

Memory management

How ARC works

Strong reference cycles

Summary

6. Using Protocols and Protocol Extensions

Protocols as types

Polymorphism with protocols

Type casting with protocols

Protocol extensions

Summary

7. Protocol-Oriented Design

Requirements

Object-oriented design

Protocol-oriented design

Protocol inheritance

Protocol composition

Animal - protocol-oriented design

Using the where statement with protocols

Summary

8. Writing Safer Code with Error Handling

Error handling prior to Swift 2.0

Native error handling

Representing errors

Throwing errors

Catching errors

Summary

9. Custom Subscripting

Introducing subscripts

Subscripts with Swift arrays

Read and write custom subscripts

Read-only custom subscripts

Calculated subscripts

Subscript values

External names for subscripts

Multidimensional subscripts

When not to use a custom subscript

Summary

10. Using Optional Types

Introducing optionals

The need for optional types in Swift

Defining an optional

Using optionals

Forced unwrapping optionals

Optional binding

Returning optionals from functions, methods, and subscripts

Using optionals as a parameter in a function or method

Optional types with tuples

Optional chaining

The nil coalescing operator

Summary

11. Working with Generics

An introduction to generics

Generic functions

Generic types

Associated types

Summary

12. Working with Closures

An introduction to closures

Simple closures

Shorthand syntax for closures

Using closures with Swift's array algorithms

Changing functionality

Selecting a closure based on results

Creating strong reference cycles with closures

Summary

13. Using C Libraries with Swift

Modules

Creating a custom module

Creating the Cpcap module

Using the Cpcap module

Linux man pages

Summary

14. Concurrency and Parallelism in Swift

Concurrency and parallelism

GCD

Helper functions

Creating queues

Creating and using a concurrent queue

Creating and using a serial queue

async versus sync

Executing code on the main queue function

Using asyncAfter

Summary

15. Swifts Core Libraries

Apple's URL loading system

URLSession

URLSessionConfiguration

URLSessionTask

URL

URLRequest

HTTPURLResponse

REST web services

Making an HTTP GET request

Making an HTTP POST request

Formatter

DateFormatter

NumberFormatter

FileManager

Summary

16. Swift on Single Board Computers

The BeagleBone Black

BeagleBone Black's expansion headers

Installing Swift

SwiftyBones3

Sources directory

SwiftyBuild

Blinking an LED with the SBDigitalGPIO type

TMP36 temperature sensor with the SBAnalog type

Autonomous robot

Summary

17. Swift Formatting and Style Guide

What is a programming style guide?

Your style guide

Do not use semicolons at the end of statements

Do not use parentheses for conditional statements

Naming

Custom types

Functions and methods

Constants and variables

Indenting

Comments

Using the self keyword

Constants and variables

Optional types

Use optional binding

Use optional chaining over optional binding for multiple unwrapping

Use type inference

Use shorthand declaration for collections

Use switch rather than multiple if statements

Don't leave commented-out code in your application

Summary

18. Adopting Design Patterns in Swift

What are design patterns?

Creational patterns

The singleton design pattern

Understanding the problem

Understanding the solution

Implementing the singleton pattern

The builder design pattern

Understanding the problem

Understanding the solution

Implementing the builder pattern

Structural design patterns

The bridge pattern

Understanding the problem

Understanding the solution

Implementing the bridge pattern

The façade pattern

Understanding the problem

Understanding the solution

Implementing the façade pattern

The proxy design pattern

Understanding the problem

Understanding the solution

Implementing the proxy pattern

Behavioral design patterns

The command design pattern

Understanding the problem

Understanding the solution

Implementing the command pattern

The strategy pattern

Understanding the problem

Understanding the solution

Implementing the strategy pattern

Summary

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部