Swift Programming The Ultimate Beginner’s Guide to Learn swift Programming Step by Step , 3nd Edition (Alexander Aronowitz NlN lnc [Aronowitz etc.) (Z-Library)

Author: Alexander Aronowitz & NlN lnc [Aronowitz, Alexander]

商业

You’ll begin with Swift programming basics—including guidelines for making your code "Swifty"—and learn how to work with Xcode and its built-in Interface Builder. Then you’ll dive step-by-step into building and customizing a basic app for taking, editing, and deleting selfies. You’ll also tune and test the app for performance and manage the app’s presence in the App Store. Swift is a general-purpose, multi-paradigm, object-oriented, functional, imperative and block structured language. It is the result of the latest research on programming languages and is built using a modern approach to safety, software design patterns by Apple Inc.. It is the brand new programming language for iOS application, macOS application, watchOS application, tvOS application. Soon it became one of top 5 programming language and gained popularity among Apple developer community over the few years of time replacing the old school Objective C. What you will learn Understand core Swift components, such as operators, collections, control flows, and functions Learn how and when to use classes, structures, and enumerations Understand how to use protocol-oriented design with extensions to write easier-to-manage code Use design patterns with Swift to solve commonly occurring design problems Apply copy-on-write for your custom value types to improve performance Add concurrency to your applications using Grand Central Dispatch and Operation Queues Implement generics to write flexible and reusable code

📄 File Format: PDF
💾 File Size: 6.8 MB
18
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
(This page has no text content)
📄 Page 2
NLN lnc
📄 Page 3
(This page has no text content)
📄 Page 4
Table of contents Introduction About Swift About the book Part I. Introducing Xcode Chapter 1. The first steps eleven . You need a Mac computer 12 . Sign up as an Apple developer thirteen . Install Xcode Chapter 2 . Xcode environment and playground projects 2 .1. Introduction to Xcode 2 .2. Playground project interface 2 .3. Playground project capabilities Part II. Basic Swift Features Chapter 3 . Starting point 3 .1. Setting and changing the value 3 .2. Variables and constants 3 .3. The rules for declaring variables and constants 3 .4. Display of text information 3 .5. Comments 3 .6. Semicolon
📄 Page 5
Chapter 4 . Data types and operations with them 4 .1. Types of data type definition 4 .2. Numeric data types 4 .3. Text data types 4 .4. Boolean values 4 .5. Type aliases 4 .6. Comparison operators Part III. Fixed assets Swift Chapter 5. Tuples 5 .1. Basic information about tuples 5 .2. Interacting with elements of a tuple Chapter 6 . Optional data types 6 .1. Optionals 6 .2. Retrieving an optional value Chapter 7. Assertions Chapter 8 . Flow control. Branching 8 .1. Condition statement if 8 .2. Guard statement 8 .3. Range operators 8 .4. The branching operator switch Chapter 9. Types of collections 9 .1. Arrays 9 .2. Sets 9 .3. Dictionaries Chapter 10. Flow control. Repetitions 10 .1. The repetition operator for 10 .2. Repeat while and repeat while statements
📄 Page 6
10 .3. Cycle management Chapter 11 . Functions 11 .1. Function declaration 11 .2. Input parameters and return value 11 .3. Function body as value 11 .4. Nested functions 11 .5. Reloading functions 11 .6. Recursive function call Chapter 12 . Closures 12 .1. Functions as closures 12 .2. Closing expressions 12 .3. Implicit return value 12 .4. Abbreviated parameter names 12 .5. Closure variables 12 .6. Capturing variables 12 .7. Array sorting method Part IV. Non-trivial features of Swift Chapter 13 . OOP as a foundation 13 .1. Instances 13 .2. Namespaces Chapter 14 . Enumerations 14 .1. Enumeration syntax 14 .2. Associated parameters 14 .3. Switch statement for enumerations 14 .4. The associated member values of the enumeration 14 .5. Properties in enumerations 14 .6. Methods in enumerations 14 .7. Operator self 14 .8. Recursive enums
📄 Page 7
Chapter 15. Structures 15 .1. Syntax for declaring structures 15 .2. Properties in structures 15 .3. Structure as a namespace 15 .4. Custom initializers 15 .5. Methods in structures Chapter 16. Classes 16 .1. Class syntax 16 .2. Class properties 16 .3. Class methods. 16 .4. Class initializers 16 .5. Nested types. Chapter 17 . Properties 17 .1. Property types. 17 .2. Control of receiving and setting values. 17 .3. Type properties. Chapter 18 . Subscripts 18 .1. Appointment of subscripts. 18 .2. Subscript syntax Chapter 19 . Inheritance 19 .1. Inheritance syntax 19 .2. Overriding inherited elements 19 .3. The preemptive final modifier 19 .4. Substitution of class instances 19 .5. Cast Chapter 20 . The aliases Any and AnyObject
📄 Page 8
20 .1. The alias is Any 20 .2. The alias is AnyObject. Chapter 21 . Initializers and Deinitializers. 21 .1. Initializers. 21 .2. Deinitializers. Chapter 22 . Removing instances and ARC 22 .1. Destruction of instances 22 .2. Memory leaks 22 .3. Automatic reference counting. Chapter 23 . Optional Chains 23 .1. Accessing properties through optional chaining 23 .2. Setting values through optional chains 23 .3. Accessing methods through optional chaining. Chapter 24 . Extensions 24 .1. Computed properties in extensions. 24 .2. Extension initializers. 24 .3. Methods in extensions. 24 .4. Subscripts in extensions. Chapter 25 . Protocols 25 .1. Required properties 25 .2. Required methods 25 .3. Required initializers 25 .4. Protocol as data type 25 .5. Extension and protocols 25 .6. Protocol inheritance 25 .7. Class protocols 25 .8. Composition of protocols Chapter 26 . Non-standard data types and retrieval reference information
📄 Page 9
Chapter 27 . Generic templates 27 .1. Versatile functions 27 .2. Generic types 27 .3. Type constraints 27 .4. Generic extensions 27 .5. Related types Chapter 28 . Error processing 28 .1. Throwing errors 28 .2. Error processing 28 .3. Delayed cleanup actions. Chapter 29 . Non-trivial use operators 29 .1. Operator functions 29 .2. Custom operators
📄 Page 10
At the annual global platform developer conference Apple (Worldwide Developers Conference, WWDC) June 2, 2014 The "apple" company pleasantly surprised the iOS-public, installing a new programming language called Swift. This came as a big surprise: the maximum that was expected developers accustomed to a language that is now a thing of the past Objective-C is an overview of the new features in iOS 8 and new features. useful programming interfaces for working with them. Recovered shocked, the developers approached Swift, studying and, of course, criticizing him. A year later, having released several intermediate new language versions, on June 8, 2015 Apple announced the release version with index 2.0, which became available with the final assembly of the mobile operating system iOS 9. Later, in the middle October of the same year, version 2.1 was released, bringing development process a number of significant innovations. If you've ever written an Objective-C application, then After learning Swift with its many possibilities, you are probably want to rewrite your applications in a new programming language- tions 1 . After the release of Swift, many developers went exactly along this path, realizing that in the future Apple's greatest attention will devote to the development of a new language. Moreover, Swift became the first open source development by
📄 Page 11
Apple, which means that implementation of its support and other operating systems (and not iOS and OS X only) 2 . 1 Swift differs significantly from Objective-C upwards convenience of programming. However, on rare occasions when developing programs you may need to use inserts written in Objective-C. 2 Currently, Swift applications can be developed not only for operating systems iOS and OS X, but also for watchOS (operating system Smart watch Apple Watch) and tvOS (television operating system 4th generation Apple TV boxes). However, learning development techniques applications for different operating systems are out of scope of this book. About Swift Swift is fast, modern, secure and user-friendly. gramming. With its help, the process of creating programs becomes very flexible and productive, as Swift has incorporated the best from languages like C, Objective-C and Java. Swift is extremely convenient to study,
📄 Page 12
perceive and read the code. It has extremely promising a vivid future. Learning this wonderful language, you will be surprised how connected it is with Xcode (development environment, we will dwell on it later) excel- gives other programming languages in which you wrote programs we are earlier. Its simplicity, brevity and incredible possibilities are simply amazing! The Swift language was created completely "from scratch", therefore it has a number of features bennities: ❑ Object oriented . Swift is an object-oriented programming language designed for adhering to the paradigm "everything is an object". If the present moment this statement seemed incomprehensible to you, did not live: a little later we will return to it. ❑ Readability , economy and conciseness of the code . Swift is simply designed to be easy to use and easy to use. easy to understand. It has a simple and transparent syntax, allowing you to shorten the multi-line code that you can but, wrote in the past, to one-lines (and in some cases - single character!) expressions. ❑ Security . Within Swift, the developers tried to create a modern a language that is free from vulnerabilities and does not require excessive knowledge straining the programmer when creating applications. Swift has strongly typed: at any given time, you know for sure those with what type of object you are working with. Moreover, when creating applications, you practically do not need to think about consumable RAM, Swift does everything for you automatically mode. ❑ Performance . Swift is a very young language, however, in terms of performance of the developed programs, it is approaching (and in some
📄 Page 13
cases already overtakes) the well-known "old man" - the language of pro grammar C ++ 1 . These features make Swift a truly amazing language. programming. Now is the time for you to dive into the world Swift: he is still very, very young, people with significant luggage knowledge and experience behind shoulders simply does not exist due to age language, so in the future you can become one of them. About the book Using modern smartphones to address emerging tasks became the norm. In this regard, many companies pay all more focus on providing functional access to the services they offer via mobile applications (whether it is an optimized internet site that opens in a browser, or special program). iOS is one of the most popular mobile operating systems in the world, and in such a situation, the demand for mobile programming is growing at an unprecedented rate. This book contains comprehensive information for everyone learning to program in the wonderful Swift language in order to creating your own iOS applications (as well as OS X-, watchOS- and tvOS apps). While reading the book, you will come across not only the theoretical information, but also a large number of practical examples and tasks, completing which you will deepen your knowledge in the studied material. Despite the fact that you have a long way to go, this it will be a rewarding and very important experience. The book doesn't show you how to write iOS application, it is designed to learn the language itself grammar Swift. I believe that it will give you the opportunity to master new language and soon start writing your own apps for the App Store or Mac App Store. Having studied the language, into the distance Then you can independently choose for which platform create programs - for iOS, OS X, tvOS, or watchOS. The code examples in this book correspond to Swift version 2.1 or higher,
📄 Page 14
iOS version at least 9.1 and Xcode version at least 7.1. If you have more new versions, do not worry, all described material with great most likely it will work for you without any errors. But the small possibility that Apple will change slightly 1 The corresponding tests are periodically conducted and posted on its portal, Primate Tabs is the developer of the popular product tester Geekbench performance. Swift syntax does exist. If you meet with such a tuation, I ask you to treat with understanding and inform me about it to the email address alkal @ ya .ru . For whom the book was written If you answer yes to the following questions ❑ You have at least minimal knowledge of programming in any high level language? ❑ You want to learn how to create programs for the operating room iOS systems (for your iPhone and iPad gadget), OS X, watchOS or tvOS? ❑ Do you prefer practical training to boring and tedious notonic theoretical lectures? Then this book is for you. The material studied in the book is supported by practical homework tasks. Together we will go from the simplest concepts to solving the most interesting problems. Do not be afraid, Swift will not scare you off at all (how could Objective-C), and the process of creating applications will be very exciting nude. And if you have an idea for an awesome app, then co- everyone will soon be able to develop it for modern mobile iOS system or stationary OS X. It is very important that you do not let your hands stand idle. Test- study all the proposed code and complete all tasks, as to learn
📄 Page 15
Programming just by reading text is not the best way. If in the course of studying new material, you will have a desire to "play" with the code from the listings - do it without delay. Comprehend Swift! Do not be afraid to make mistakes, as while you are learning, mistakes are yours. friends. And to correct mistakes and avoid them in the future will help you this book and the Xcode development environment (we'll talk about it later). Remember: Becoming a Great Programmer requires time! Be patient and study the material carefully. Book structure The book consists of four large parts ❑ Part I . Familiarity with Xcode . In the first part, you will start your journey Journey into the world of Swift, complete the most important and must steps prior to starting to develop your own applications niy. Learn how to create your own Apple account ID, how to connect to the apple developers program, where to get development environment for Swift applications, how to work with it. ❑ Part II . Basic features of Swift . After getting to know the environment development of Xcode, allowing you to start learning the language programming, you will learn the basic features of Swift. You learn what syntax Swift has, what variables and con- stants, what types of data exist and how all these to be involved in developing programs. ❑ Part III . Fixed assets of Swift . The third part focuses on consideration and study of the most simple, but very interesting Swift tools. About some of them (for example, about tuples) you, may have never heard of others (like arrays) you, probably used in other languages as well. ❑ Part IV . Non-trivial features of Swift . At the fourth hour methods of working with the most powerful
📄 Page 16
and Swift functionality. In this chapter, you you will use it with enviable regularity when creating your own applications in the future. Legend NOTE This block contains notes and notes. CAUTION This is what important material notes look like. Listing And these are code examples (listings) SYNTAX In such blocks, syntactic constructions are given with an explanation of the options their use. The task You will find tasks to complete in separate sections.
📄 Page 17
Part I Introducing Xcode In the first part, you will learn what you need to start developing Swift applications. You will get your own custom account employee, get acquainted with the application development environment called Xcode, and learn the first and most important interaction skills with her . NOTE If you are unable to meet all the requirements of this parts, do not despair. To get started learning Swift, you can use use the special service http: // swiftstub .com /, which will allow you to write Swift code directly in the browser and see the results of its execution there. If you've never worked with Xcode before, you'll be amazed the breadth of its capabilities and an unusual approach to the development of applications ny (unlike many other programming environments). Naturally, not all of these possibilities are covered in the book, so I advise you in the future independently continue to study it In case you already have experience with Xcode, you can skip this chapter and go directly to learning the Swift language, although this and not recommended. ✓ Chapter 1. The first steps ✓ Chapter 2. Xcode and Playground projects
📄 Page 18
1 First steps eleven . You need a Mac computer Before you start developing programs in Swift, you it will take a few things. First you need a computer iMac, MacBook, Mac mini, or Mac Pro with an operating Mavericks (OS X 10.9), Yosemite (OS X 10.10), or El Capitan system (OS X 10.11). This first and basic requirement is due to the fact that the environment Xcode application development is created by Apple exclusively but with a focus on its own platform. Although due to the fact that Swift is an open language, there may already be projects that allowing the development of applications for other operating rooms systems. NOTE If you have a Windows computer and do not have a separate computer with OS X, you should choose one of three ways to solve this Problems: - purchase a Mac with OS X installed; - install OS X (or rather, Hackintosh) on your computer; - install a virtual machine in Windows and deploy the finished image on it OS X. I note that the method with installing a virtual machine is the simplest and acceptable, although in this case you will not achieve the same level of comfort work as it did on the original Mac. 12 . Sign up as an Apple developer The next step is to get an Apple ID account and registration with the Apple Developer Center. This requires follow the link https: // developer .apple .com / register / in your browser (fig. 1.1).
📄 Page 19
Figure: 1.1. Developer Center login page NOTE Apple ID is an account that allows you to receive access to services provided by Apple. You may already have a personal Apple ID account. It is used, for example, when purchasing mobile devices. in the AppStore or when working with the iCloud .com portal. To create a new Apple ID, follow the link Create Apple ID . To register, you will need to enter the required data and click on the button at the bottom of the form. If you already have an Apple ID account, then use the data your account to sign in to the Developer Center ( Sign In button ). On the start page of the Developer Center, go to follow the link SDKs , after which you will have access to all the variety of options features of the Apple Developer Center (Figure 1.2). In the Developer Center, you can access a huge amount of various documentation, videos, code examples - to everything, which will help you create great apps. Registration as a developer is free. That is, everyone can start developing applications without paying any drinks (if you do not take into account the cost of the computer) Nevertheless for $ 99 per year you can participate in a paid program iOS developers (iOS Developer Program), which offers you Apple is burning. This is optional, but if you want to test your
📄 Page 20
applications on real devices (and not only in software simulator) and use the App Store (mobile app store zheniy) to distribute their programs, then participation in the program becomes mandatory. Personally, I advise you not to think about it for now, since everyone is iOS development ki can be obtained with a free account entries and Xcode. thirteen . Install Xcode Now all you need to do is download Xcode. To do this go by the corresponding link in the Developer Center to the page, sacred to this wonderful development environment (fig. 1.3). NOTE As you can see, Apple is giving you beta access versions of Xcode. I strongly discourage using them when learning a language programming as they are intended for experienced Apple developers. After clicking on the View in the Mac App Store link, an automatic Cycle to the Mac App Store to a page Xcode. Here you can see a summary of all the main development environment features, an overview of the latest update and user calls. To download Xcode just click on the Download button and, if necessary, enter your account details Apple ID records. Once the installation process is complete, you should be able to find Xcode in Launchpad or in the Applications folder in the Dock.
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now
Back to List