Ios 11 Programming Fundamentals Swift Free Download PDF - Programming Ebook

Latest

Download Programming Ebook

Facebook Page

Tuesday, November 21, 2017

Ios 11 Programming Fundamentals Swift Free Download PDF

Ios 11 Programming Fundamentals Swift
Ios 11 Programming Fundamentals Swift



Book Details 
             TitleIos 11 Programming Fundamentals Swift
      ISBN-10925878347
         Author: Matt Neuburg
     PublisherMatt Neuburg
    Language: English
        SubjectSwift / Computers & Technology / Programming / Apple Programming
No. of pages: 645
         Format: PDF


Preface


On June 2, 2014, Apple’s WWDC keynote address ended with a shocking announce‐ ment: “We have a new programming language.” This came as a huge surprise to the developer community, which was accustomed to Objective-C, warts and all, and doubted that Apple could ever possibly relieve them from the weight of its venerable legacy. The developer community, it appeared, had been wrong.

Having picked themselves up off the floor, developers immediately began to consider this new language — Swift — studying it, critiquing it, and deciding whether to use it. My own first move was to translate all my existing iOS apps into Swift; this was enough to convince me that, for all its faults, Swift deserved to be adopted by new students of iOS programming, and that my books, therefore, should henceforth assume that readers are using Swift.

Three years later, that decision has proven prophetic. Programmers of iOS have flocked to Swift in increasing numbers, and Swift itself has only improved. My iOS apps (such as Diabelli’s Theme, LinkSame, Zotz!, TidBITS News, and my Latin and Greek flashcard apps) have all been rewritten in Swift, and are far easier for me to understand and maintain than their Objective-C originals.

Xcode 9 comes with Swift 4. The language has evolved greatly in its details and in the nature of its integration with the Cocoa libraries that underlie iOS programming, but its spirit has remained constant. The Swift language is designed from the ground up with these salient features:

Object-orientation

Swift is a modern, object-oriented language. It is purely object-oriented: “Every‐ thing is an object.”

Clarity

Swift is easy to read and easy to write. Its syntax is clear, consistent, and explicit, with few hidden shortcuts and minimal syntactic trickery.

Swift enforces strong typing to ensure that it knows, and that you know, what the type of every object reference is at every moment.

Economy

Swift is a fairly small language, providing some basic types and functionalities and no more. The rest must be provided by your code, or by libraries of code that you use — such as Cocoa.

Memory management

Swift manages memory automatically. You will rarely have to concern yourself with memory management.

Cocoa compatibility

The Cocoa APIs are written primarily in C and Objective-C. Swift is explicitly designed to interface with most of the Cocoa APIs.

 iOS 11 by Tutorials Ray Wenderlich, IOS 11 and Swift 4 PDF - EPUB - Full source code


These features make Swift an excellent language for learning to program iOS.

The alternative, Objective-C, still exists, and you can use it if you like. Indeed, it is easy to write an app that includes both Swift code and Objective-C code; and you may have reason to do so. Objective-C, however, lacks the very advantages that Swift offers. Objective-C agglomerates object-oriented features onto C. It is therefore only partially object-oriented; it has both objects and scalar data types, and its objects have to be slotted into one particular C data type (pointers). Its syntax can be difficult and tricky; reading and writing nested method calls can make one’s eyes glaze over, and it invites hacky habits such as implicit nil-testing. Its type checking can be and fre‐ quently is turned off, resulting in programmer errors where a message is sent to the wrong type of object and the program crashes.

Recent revisions and additions to Objective-C — ARC, synthesis and autosynthesis, improved literal array and dictionary syntax, blocks — have made it easier and more convenient, but such patches have also made the language even larger and possibly even more confusing. Because Objective-C must encompass C, there are limits to how far it can be extended and revised. Swift, on the other hand, is a clean start. If you were to dream of completely revising Objective-C to create a better Objective-C, Swift might be what you would dream of. It puts a modern, rational front end between you and the Cocoa Objective-C APIs.

Still, the reader will also need some awareness of Objective-C (including C). The Foundation and Cocoa APIs, the built-in commands with which your code must interact in order to make anything happen on an iOS device, are still written in C and Objective-C. In order to interact with them, you have to know what those languages would expect. For example, in order to pass a Swift array where an NSArray is expected, you need to know what constitutes an object acceptable as an element of an Objective-C NSArray.

Therefore, although I do not attempt to teach Objective-C in this book, I do describe it in enough detail to allow you to read it when you encounter it in the documenta‐ tion and on the Internet, and I occasionally show some Objective-C code. Part III, on Cocoa, is really all about learning to think the way Objective-C thinks — because the structure and behavior of the Cocoa APIs are fundamentally based on Objective-C. And the book ends with an appendix that details how Swift and Objective-C commu‐ nicate with one another, as well as explaining how your app can be written partly in Swift and partly in Objective-C.

The Scope of This Book

This book is actually one of a pair with my Programming iOS 11, which picks up exactly where this book leaves off. They complement and supplement one another. The two-book architecture should, I believe, render the size and scope of each book tractable for readers. Together, they provide a complete grounding in the knowledge needed to begin writing iOS apps; thus, when you do start writing iOS apps, you’ll have a solid and rigorous understanding of what you are doing and where you are heading. If writing an iOS program is like building a house of bricks, this book teaches you what a brick is and how to handle it, while Programming iOS 11 hands you some actual bricks and tells you how to assemble them.

When you have read this book, you’ll know about Swift, Xcode, and the underpin‐ nings of the Cocoa framework, and you will be ready to proceed directly to Program‐ ming iOS 11. Conversely, Programming iOS 11 assumes a knowledge of this book; it begins, like Homer’s Iliad, in the middle of the story, with the reader jumping with all four feet into views and view controllers, and with a knowledge of the language and the Xcode IDE already presupposed. If you started reading Programming iOS 11 and wondered about such unexplained matters as Swift language basics, the UIApplicationMain function, the nib-loading mechanism, Cocoa patterns of delega‐ tion and notification, and retain cycles, wonder no longer — I didn’t explain them there because I do explain them here.

The three parts of this book teach the underlying basis of all iOS programming:

Part I introduces the Swift language, from the ground up — I do not assume that you know any other programming languages. My way of teaching Swift is differ‐ ent from other treatments, such as Apple’s; it is systematic and Euclidean, with pedagogical building blocks piled on one another in what I regard as the most helpful order. At the same time, I have tried to confine myself to the essentials. Swift is not a big language, but it has some subtle and unusual corners. You don’t need to dive deep into all of these, and my discussion will leave many of them unexplored. You will probably never encounter them, and if you do, you will have entered an advanced Swift world outside the scope of this discussion. To give an obvious example, readers may be surprised to find that I never mention


Swift playgrounds or the REPL. My focus here is real-life iOS programming, and my explanation of Swift therefore concentrates on those common, practical aspects of the language that, in my experience, actually come into play in the course of programming iOS.

Part II turns to Xcode, the world in which all iOS programming ultimately takes place. It explains what an Xcode project is and how it is transformed into an app, and how to work comfortably and nimbly with Xcode to consult the documenta‐ tion and to write, navigate, and debug code, as well as how to bring your app through the subsequent stages of running on a device and submission to the App Store. There is also a very important chapter on nibs and the nib editor (Interface Builder), including outlets and actions as well as the mechanics of nib loading; however, such specialized topics as autolayout constraints in the nib are post‐ poned to the other book.

Part III introduces the Cocoa Touch framework. When you program for iOS, you take advantage of a suite of frameworks provided by Apple. These frameworks, taken together, constitute Cocoa; the brand of Cocoa that provides the API for programming iOS is Cocoa Touch. Your code will ultimately be almost entirely about communicating with Cocoa. The Cocoa Touch frameworks provide the underlying functionality that any iOS app needs to have. But to use a framework, you have to think the way the framework thinks, put your code where the frame‐ work expects it, and fulfill many obligations imposed on you by the framework. To make things even more interesting, Cocoa uses Objective-C, while you’ll be using Swift: you need to know how your Swift code will interface with Cocoa’s features and behaviors. Cocoa provides important foundational classes and adds linguistic and architectural devices such as categories, protocols, delegation, and notifications, as well as the pervasive responsibilities of memory management. Key–value coding and key–value observing are also discussed here.

The reader of this book will thus get a thorough grounding in the fundamental knowledge and techniques that any good iOS programmer needs. The book itself doesn’t show how to write any particularly interesting iOS apps, but it does constantly use my own real apps and real programming situations to illustrate and motivate its explanations. And then you’ll be ready for Programming iOS 11, of course! 


Version

This book is geared to Swift 4, iOS 11, and Xcode 9.
In general, only very minimal attention is given to earlier versions of iOS and Xcode. It is not my intention to embrace in this book any detailed knowledge about earlier versions of the software, which is, after all, readily and compendiously available in my


earlier books. The book does contain, nevertheless, a few words of advice about back‐ ward compatibility (especially in Chapter 9).

A word about method names. I generally give method names in Swift, in the style of a function reference (as described in Chapter 2) — that is, the name plus parentheses containing the parameter labels followed by colon. Now and then, if a method is already under discussion and there is no ambiguity, I’ll use the bare name. In a few places, such as Appendix A, where the Objective-C language is explicitly under dis‐ cussion, I use Objective-C method names.

Please bear in mind that Apple continues to make adjustments to the Swift language. I have tried to keep my code up-to-date right up to the moment when the manuscript left my hands; but if, at some future time, a new version of Xcode is released along with a new version of Swift, some of the code in this book, and even some informa‐ tion about Swift itself, might be slightly incorrect. Please make allowances, and be prepared to compensate.

Screenshots of Xcode were taken using Xcode 9 under macOS 10.12 Sierra. I have not upgraded my machine to macOS 10.13 High Sierra, because at the time of this writing it was too new to be trusted with mission-critical work. If you are braver than I am and running High Sierra, your interface may naturally look very slightly different from the screenshots, but this difference will be minimal and shouldn’t cause any confusion. 

No comments:

Post a Comment