万本电子书0元读

万本电子书0元读

顶部广告

Swift: Developing iOS Applications电子书

售       价:¥

3人正在读 | 0人评论 9.8

作       者:Andrew J Wagner,Giordano Scalzo,Jon Hoffman

出  版  社:Packt Publishing

出版时间:2016-08-01

字       数:975.4万

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

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

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Unleash the power of Swift and discover the skills required to build incredible robust iOS applications About This Book Write expressive, understandable, and maintainable Swift 2 code with this hands-on course Unveil the complex underpinnings of Swift to turn your app ideas into reality Specialize in developing real iOS apps, and 2D and 3D video games using Swift and Cocoapods Dive deep into protocol extensions, learn new error handling model and use featured Swift design patterns to write more efficient code Who This Book Is For This course would be for app developers who are new to developing for iOS or OSX and are trying to get grips with Swift for the first time. What You Will Learn From a solid understanding of the Swift 2 language Get to know the practical aspects of how a computer program actually works Understand the paradigms used by Apple’s frameworks, so you are not intimidated by them Create a server in Swift to deliver JSON data to an iOS app Take advantage of Cocoapods to use third-party libraries Build games with SpriteKit and SceneKit Develop an app running on the cloud to act as an API server for your client’s apps Dive into the core components of Swift 2 including operators, collections, control flow, and functions Create and use classes, structures, and enums including object-oriented topics such as inheritance, protocols, and extensions Develop a practical understanding of sub*s, optionals, and closures Master Objective-C interoperability with mix and match Access network resources using Swift Implement various standard design patterns in the Swift language In Detail The Swift––Developing iOS Applications course will take you on a journey to become an efficient iOS and OS X developer, with the latest trending topic in town. Right from the basics to the advanced level topics, this course would cover everything in detail. We’ll embark our journey by dividing the learning path into four modules. Each of these modules are a mini course in their own right; and as you complete each one, you’ll gain key skills and be ready for the material in the next module. The first module is like a step-by-step guide to programming in Swift 2. Each topic is separated into compressible sections that are full of practical examples and easy-to-understand explanations. Each section builds on the previous topics, so you can develop a proficient and comprehensive understanding of app development in Swift 2. By the end of this module, you’ll have a basic understanding of Swift 2 and its functionalities. The second module will be the an easy-to-follow guide filled with tutorials to show you how to build real-world apps. The difficulty and complexity level increases chapter by chapter. Each chapter is dedicated to build a new app, beginning from a basic and unstyled app through to a full 3D game. The last two chapters show you how to build a complete client-server e-commerce app right from scratch. You’ll be able to build well-designed apps, effectively use AutoLayout, develop videogames, and build server apps. The third and the last module of our course will take an example-based approach where each concept covered is supported by example code to not only give you a good understanding of the concept, but also to demonstrate how to properly implement it. Style and approach This course includes all the resources that will help you jump into the app development .This course covers all the important aspects Swift application development and is divided into individual modules so that you develop your skill after the completion of a module and get ready for the next. Through this comprehensive course, you'll learn how to use Swift programming with hands-on examples from scratch to finish!
目录展开

Swift: Developing iOS Applications

Table of Contents

Swift: Developing iOS Applications

Swift: Developing iOS Applications

Credits

Preface

What this learning path covers

What you need for this learning path

Who this learning path is for

Reader feedback

Customer support

Downloading the example code

Errata

Piracy

Questions

1. Module 1

1. Introducing Swift

Defining our goals for this book

Setting up the development environment

Running our first swift code

Understanding playgrounds

Learning with this book

Summary

2. Building Blocks – Variables, Collections, and Flow Control

Core Swift types

Constants and variables

Containers

Tuples

Arrays

Dictionaries

Swift's type system

Printing to the console

Control flow

Conditionals

Switches

Loops

Functions

Basic functions

Parameterized functions

Functions that return values

Functions with default arguments

Guard statement

Bringing it all together

Summary

3. One Piece at a Time – Types, Scopes, and Projects

Structs

Types versus instances

Properties

Member and static methods

Computed properties

Reacting to property changes

Subscripts

Custom initialization

Classes

Inheriting from another class

Initialization

Overriding initializer

Required initializer

Designated and convenience initializers

Overriding methods and computed properties

Methods

Computed properties

Casting

Upcasting

Downcasting

Enumerations

Basic declaration

Testing enumeration values

Raw values

Associated values

Methods and properties

Projects

Setting up a command-line Xcode project

Creating and using an external file

Interfacing with code from other files

File organization and navigation

Extensions

Scope

How scope is defined

Nested types

Access control

Summary

4. To Be or Not To Be – Optionals

Defining an optional

Unwrapping an optional

Optional binding

Forced unwrapping

Nil coalescing

Optional chaining

Implicitly unwrapped optionals

Debugging optionals

The underlying implementation

Summary

5. A Modern Paradigm – Closures and Functional Programming

Functional programming philosophy

State and side effects

Declarative versus imperative code

Closures

Closures as variables

Closures as parameters

Syntactic sugar

Building blocks of functional programming in Swift

Filter

Reduce

Map

Sort

How these affect the state and nature of code

Lazy evaluation

Example

Summary

6. Make Swift Work For You – Protocols and Generics

Protocols

Defining a protocol

Implementing a protocol

Using type aliases

Generics

Generic function

Generic type

Type constraints

Protocol constraints

Where clauses for protocols

Where clauses for equality

Extending generics

Adding methods to all forms of a generic

Adding methods to only certain instances of a generic

Extending protocols

Putting protocols and generics to use

Generators

Sequences

Product of Fibonacci numbers under 50

Summary

7. Everything Is Connected – Memory Management

Computer data storage

File system

Memory

Value types versus reference types

Determining value type or reference type

Behavior on assignment

Behavior on input

Closure capture behavior

Automatic reference counting

Object relationships

Strong

Weak

Unowned

Strong reference cycles

Between objects

Spotting

Fixing

With closures

Spotting

Fixing

Lost objects

Between objects

With closures

Structures versus classes

Summary

8. Paths Less Traveled – Error Handling

Throwing errors

Defining an error type

Defining a function that throws an error

Implementing a function that throws an error

Handling errors

Forceful try

Optional try

Catching an error

Propagating errors

Cleaning up in error situations

Order of execution when errors occur

Deferring execution

Summary

9. Writing Code the Swift Way – Design Patterns and Techniques

What is a design pattern?

Behavioral patterns

Iterator

Observer

Callback

Notification center

Structural patterns

Composite

Hierarchies

Alternative to subclassing

Delegate

Model view controller

Creational patterns

Singleton/shared instance

Abstract factory

Using associated values effectively

Replacing class hierarchies

Concisely representing state

Extending system types to reduce code

Lazy properties

Avoiding unnecessary memory usage

Avoiding unnecessary processing

Localizing logic to the concerned property

Summary

10. Harnessing the Past – Understanding and Translating Objective-C

Swift's relationship to Objective-C

Background of Objective-C

Constants and variables

Value types

Reference types

Containers

Arrays

Dictionaries

Control flow

Conditionals

Switches

Loops

Functions

Types

Structures

Enumerations

Classes

Basic class

Initializers

Properties

Methods

Inheritance

Categories

Protocols

Blocks

Projects

Header files

Implementation files

Organization

Calling Objective-C code from Swift

Bridging header

Using functions

Using types

Containers

Annotations

Nullability

Container element types

Summary

11. A Whole New World – Developing an App

Conceptualizing the app

Features

Interface

Data

Setting up the app project

Configuring the user interface

Running the app

Allowing picture taking

Temporarily saving a photo

Populating our photo grid

Refactoring to respect model-view-controller

Permanently saving a photo

Summary

12. What's Next? – Resources, Advice, and the Next Steps

Apple's documentation

Forums and blogs

Blog posts

Forums

Prominent figures

Podcasts

Summary

2. Module 2

1. Welcome to the World of Swift

The first look at Swift

Let's go to the playground

The building blocks – variables and constants

Collecting variables in containers

Controlling the flow

Transforming the values using functions

Structs – custom compound types

Classes – common behavior objects

Loose coupling with protocols

Composing objects using protocol extensions

Checking the existence of an optional value

Enumerations on steroids

Extended pattern matching

Catching errors

Swift functional programming patterns

Summary

2. Building a Guess the Number App

The app is…

Building a skeleton app

Adding the graphics components

Connecting the dots

Adding the code

Summary

3. A Memory Game in Swift

The app is…

Building the skeleton of the app

The menu screen

Implementing the basic menu screen

Creating a nice menu screen

The game screen

The structure

Adding a collection view

Sizing the components

Connecting the dataSource and the delegate

Implementing a deck of cards

What we are expecting

The card entity

Crafting the deck

Shuffling the deck

Finishing the deck

Put the cards on the table

Adding the assets

The CardCell structure

Handling touches

Finishing the game

Implementing the game logic

We got a pair

We made the wrong move

Et voilà! The game is completed

Summary

4. A TodoList App in Swift

The app is…

Building a skeleton app

Implementing an empty app

Adding third-party libraries with CocoaPods

Implementing the Todos view controller

Building the Todos screen

Adding entities

Implementing datastore

Connecting datastore and View Controller

Configuring tableView

Finishing touches

Swipe that cell!

Adding a Todo task

The add a Todo view

The add a Todo View Controller

Finishing TodoDatastore

List View Controller

Where do we go from here?

Summary

5. A Pretty Weather App

The app is…

Building the skeleton

Creating the project

Adding assets

Implementing the UI

The UI in blocks

Completing the UI

Implementing CurrentWeatherView

Building WeatherHourlyForecastView

Seeing the next day's forecast in WeatherDaysForecastView

Blurring the background

Downloading the background image

Searching in Flickr

Geolocalising the app

Using Core Location

Retrieving the actual forecast

Getting the forecast from OpenWeatherMap

Rendering CurrentWeatherView

Rendering WeatherHourlyForecastView

Rendering WeatherDaysForecastView

Connecting to the server

Where do we go from here?

Summary

6. Flappy Swift

The app is…

Building the skeleton of the app

Creating the project

Implementing the menu

A stage for a bird

SpriteKit in a nutshell

Explaining the code

Simulating a three-dimensional world using parallax

How to implement scrolling

A flying bird

Adding the Bird node

Making the bird flap

Pipes!

Implementing the pipes node

Making the components interact

Setting up the collision-detection engine

Completing the game

Colliding with pipes

Adding the score

Adding a restart pop-up

Summary

7. Polishing Flappy Swift

Adding juiciness

Let there be sounds!

Playing the soundtrack

Shaking the screen!

Integrating with Game Center

What Game Center provides

Setting up Game Center

Creating an app record on iTunes Connect

Enabling Game Center

Creating fake user accounts to test Game Center

Authenticating a player

Summary

8. Cube Runner

The app is…

Introduction to SceneKit

What is SceneKit?

Building an empty scene

Adding a green torus

Let there be light!

Let's make it move!

Implementing Cube Runner

The game skeleton

Implementing the menu

Flying in a 3D world

Setting up a scene

Adding a fighter

Texturing the world

Make it move

Adding cubes

Adding more obstacles

Adding a few touches

The score

Let's add music

Summary

9. Completing Cube Runner

Creating a real game

Detecting collisions

Game over!

Adding the juice

Game Center

Summary

10. ASAP – an E-commerce App in Swift

The app is…

The first requirement: login and registration

The second requirement: the products grid

The third requirement: the open cart

The skeleton app and register screen

The skeleton app

The ASAP e-commerce store

The e-commerce product list

The product cell

Parsing and storing products

The ASAP cart

Adding a product to the cart

Removing items from cart and checkout

Summary

11. ASAPServer, a Server in Swift

The interface of the ASAP Server

One skeleton server for two OSes

An OS X skeleton server

Preparing the OS X environment

The HelloWorld skeleton server

Preparing the Linux environment

The ASAPServer

The Products

The cart

The order

Connecting the ASAP app

The products

The Cart

The order

Summary

3. Module 3

1. Taking the First Steps with Swift

What is Swift?

Swift features

Playgrounds

Getting started with Playgrounds

iOS and OS X Playgrounds

Showing images in a Playground

Creating and displaying graphs in Playgrounds

What Playgrounds are not

Swift language syntax

Comments

Semicolons

Parentheses

Curly braces

An assignment operator does not return a value

Spaces are optional in conditional and assignment statements

Hello World

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

Increment and decrement operators

Compound assignment operators

The ternary conditional operator

The logical NOT operator

The logical AND operator

The logical OR operator

Summary

3. Using Collections and Cocoa Data Types

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

sortInPlace

sort

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

Using Cocoa data types

NSNumber

NSString

NSArray

NSDictionary

Foundation data types

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 loops

Using the for loop variant

Using the for-in loop variant

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 multiparameter function

Defining a parameter's default values

Returning multiple values from a function

Returning optional values

Adding external parameter names

Using variadic parameters

Parameters as variables

Using 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

Optional requirements

Extensions

Memory management

Reference versus value types

The working of ARC

Strong reference cycles

Summary

6. Using Protocols and Protocol Extensions

Protocols as types

Polymorphism with protocols

Type casting with protocols

Protocol extensions

Summary

7. Writing Safer Code with Availability and Error Handling

Error handling prior to Swift 2.0

Error handling in Swift 2

Representing errors

Throwing errors

Catching errors

The availability attribute

Summary

8. Working with XML and JSON Data

XML and JSON

Common files

XML and the NSXMLParser class

Using the NSXMLParserDelegate protocol

Parsing XML documents

XML and NSXMLDocument

XML and manually building XML documents

JSON and NSJSONSerialization

Parsing a JSON document

Creating a JSON document

Summary

9. Custom Subscripting

Introducing subscripts

Subscripts with Swift arrays

Read and write custom subscripts

Read-only custom subscripts

Calculated subscripts

Subscript values

Subscripts with ranges

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 an optional

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

Standalone closures and good style guidelines

Changing functionality

Selecting a closure based on results

Creating strong reference cycles with closures

Summary

13. Using Mix and Match

What is mix and match

Using Swift and Objective-C together in the same project

Creating the project

Adding Swift file to the Objective-C project

The Objective-C bridging header file – part 1

Adding the Objective-C file to the project

The Messages Objective-C class

The Objective-C bridging header file – part 2

The MessageBuilder Swift class – accessing Objective-C code from Swift

The Objective-C class – accessing Swift code from Objective-C

Summary

14. Concurrency and Parallelism in Swift

Concurrency and parallelism

Grand Central Dispatch

Creating and managing dispatch queues

Creating queues with the dispatch_queue_create() function

Creating concurrent dispatch queues with the dispatch_queue_create() function

Creating a serial dispatch queue with the dispatch_queue_create() function

Requesting concurrent queues with the dispatch_get_global_queue() function

Requesting the main queue with the dispatch_get_main_queue() function

Using the dispatch_after() function

Using the dispatch_once() function

Using NSOperation and NSOperationQueue types

Using the NSBlockOperation implementation of NSOperation

Using the addOperationWithBlock() method of the operation queue

Subclassing the NSOperation class

Summary

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

Classes

Functions and methods

Constants and variables

Indenting

Comments

Using the self keyword

Types

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 for-in loops over for loops

Use switch rather than multiple if statements

Don't leave commented-out code in your application

Grand Central Dispatch

Set the attribute in the dispatch_queue_create() function

Use a reverse DNS name for the tag parameter of the dispatch_queue_create() function

Use dispatch_get_global_queue() over dispatch_queue_create()

Summary

16. Network Development with Swift

What is network development?

An overview of the URL session classes

NSURLSession

NSURLSessionConfiguration

NSURLSessionTask

Using the NSURL class

NSMutableURLRequest

NSURLHTTPResponse

REST web services

Making an HTTP GET request

Making an HTTP POST request

Checking network connection

RSNetworking2 for Swift 2

RSURLRequest

RSTransaction and RSTransactionRequest

RSTransaction

RSTransactionRequest

Extensions

Summary

17. Adopting Design Patterns in Swift

Value versus reference types

What are design patterns

Creational patterns

The singleton design pattern

The builder design pattern

The factory method pattern

Structural design patterns

The bridge pattern

The façade pattern

The proxy design pattern

Behavioral design patterns

The command design pattern

The strategy pattern

Summary

A. Biblography

Index

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

发表评论

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

买过这本书的人还买过

读了这本书的人还在读

回顶部