万本电子书0元读

万本电子书0元读

顶部广告

Object–Oriented Programming with Swift 2电子书

售       价:¥

2人正在读 | 0人评论 9.8

作       者:Gastón C. Hillar

出  版  社:Packt Publishing

出版时间:2016-01-28

字       数:44.4万

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

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

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Get to grips with object-oriented programming in Swift to efficiently build powerful real-world applicationsAbout This BookLeverage the most efficient object-oriented design patterns in your Swift applicationsWrite robust, safer, and better code using the blueprints that generate objectsBuild a platform with object-oriented code by using real-world elements and represent them in your appWho This Book Is ForIf you are an iOS developer who has a basic idea of object-oriented programming and want to incorporate its concepts with Swift to optimize your application's code and create reusable and easily to understand building blocks, then this book is for you. This is a very useful resource for developers who want to shift from Objective C, C#, Java, Python, JavaScript, or other object-oriented languages to SwiftWhat You Will LearnBuild solid, stable, and reliable applications using SwiftWork with encapsulation, abstraction, and polymorphism using Swift 2.0Customize constructors and destructors based on your needsDevelop Swift 2.0 with classes, instances, properties, and methodsTake advantage of generic code to maximize code reuse and generalize behaviorsUse state of inheritance, specialization, and the possibility to overload membersWrite high quality object-oriented code to build apps for iOS or Mac OS XIn DetailObject-Oriented Programming (OOP) is a programming paradigm based on the concept of objects; these are data structures that contain data in the form of fields, often known as attributes and code. Objects are everywhere, and so it is very important to recognize elements, known as objects, from real-world situations and know how they can easily be translated into object-oriented code.Object-Oriented Programming with Swift is an easy-to-follow guide packed full of hands-on examples of solutions to common problems encountered with object-oriented code in Swift. It starts by helping you to recognize objects using real-life scenarios and demonstrates how working with them makes it simpler to write code that is easy to understand and reuse.You will learn to protect and hide data with the data encapsulation features of Swift. Then, you will explore how to maximize code reuse by writing code capable of working with objects of different types. After that, you'll discover the power of parametric polymorphism and will combine generic code with inheritance and multiple inheritance. Later, you move on to refactoring your existing code and organizing your source for easy maintenance and extensions.By the end of the book, you will be able to create better, stronger, and more reusable code, which will help you build better applications.Style and approachThis simple guide is packed with practical examples of solutions to common problems. Each chapter includes exercises and the possibility for you to test your progress by answering questions.
目录展开

Object–Oriented Programming with Swift 2

Table of Contents

Object–Oriented Programming with Swift 2

Credits

About the Author

About the Reviewers

www.PacktPub.com

Support files, eBooks, discount offers, and more

Why subscribe?

Free access for Packt account holders

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

eBooks, discount offers, and more

Questions

1. Objects from the Real World to Playground

Installing the required software

Capturing objects from the real world

Generating classes to create objects

Recognizing variables and constants to create properties

Recognizing actions to create methods

Organizing classes with UML diagrams

Working with API objects in the Xcode Playground

Exercises

Test your knowledge

Summary

2. Structures, Classes, and Instances

Understanding structures, classes, and instances

Understanding initialization and its customization

Understanding deinitialization and its customization

Understanding automatic reference counting

Declaring classes

Customizing initialization

Customizing deinitialization

Creating the instances of classes

Exercises

Test your knowledge

Summary

3. Encapsulation of Data with Properties

Understanding the elements that compose a class

Declaring stored properties

Generating computed properties with setters and getters

Combining setters, getters, and a related property

Understanding property observers

Transforming values with setters and getters

Using type properties to create values shared by all the instances of a class

Creating mutable classes

Building immutable classes

Exercises

Test your knowledge

Summary

4. Inheritance, Abstraction, and Specialization

Creating class hierarchies to abstract and specialize behavior

Understanding inheritance

Declaring classes that inherit from another class

Overriding and overloading methods

Overriding properties

Controlling whether subclasses can or cannot override members

Working with typecasting and polymorphism

Taking advantage of operator overloading

Declaring operator functions for specific subclasses

Exercises

Test your knowledge

Summary

5. Contract Programming with Protocols

Understanding how protocols work in combination with classes

Declaring protocols

Declaring classes that adopt protocols

Taking advantage of the multiple inheritance of protocols

Combining inheritance and protocols

Working with methods that receive protocols as arguments

Downcasting with protocols and classes

Treating instances of a protocol type as a different subclass

Specifying requirements for properties

Specifying requirements for methods

Combining class inheritance with protocol inheritance

Exercises

Test your knowledge

Summary

6. Maximization of Code Reuse with Generic Code

Understanding parametric polymorphism and generic code

Declaring a protocol to be used as a constraint

Declaring a class that conforms to multiple protocols

Declaring subclasses that inherit the conformance to protocols

Declaring a class that works with a constrained generic type

Using a generic class for multiple types

Combining initializer requirements in protocols with generic types

Declaring associated types in protocols

Creating shortcuts with subscripts

Declaring a class that works with two constrained generic types

Using a generic class with two generic type parameters

Inheriting and adding associated types in protocols

Generalizing existing classes with generics

Extending base types to conform to custom protocols

Test your knowledge

Exercises

Summary

7. Object-Oriented Programming and Functional Programming

Refactoring code to take advantage of object-oriented programming

Understanding functions as first-class citizens

Working with function types within classes

Creating a functional version of array filtering

Writing equivalent closures with simplified code

Creating a data repository with generics and protocols

Filtering arrays with complex conditions

Using map to transform values

Combining map with reduce

Chaining filter, map, and reduce

Solving algorithms with reduce

Exercises

Test your knowledge

Summary

8. Extending and Building Object-Oriented Code

Putting together all the pieces of the object-oriented puzzle

Adding methods with extensions

Adding computed properties to a base type with extensions

Declaring new convenience initializers with extensions

Defining subscripts with extensions

Working with object-oriented code in apps

Adding an object-oriented data repository to a project

Interacting with an object-oriented data repository through Picker View

Exercises

Test your knowledge

Summary

A. Exercise Answers

Chapter 1, Objects from the Real World to Playground

Chapter 2, Structures, Classes, and Instances

Chapter 3, Encapsulation of Data with Properties

Chapter 4, Inheritance, Abstraction, and Specialization

Chapter 5, Contract Programming with Protocols

Chapter 6, Maximization of Code Reuse with Generic Code

Chapter 7, Object-Oriented Programming and Functional Programming

Chapter 8, Extending and Building Object-Oriented Code

Index

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

发表评论

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

买过这本书的人还买过

读了这本书的人还在读

回顶部