This ebook is for intermediate Swift builders who already know the fundamentals of Swift and want to deepen their information and understanding of the language.
- Protocols & Generics
- Numerics & Ranges
- Sequences & Collections
- Unsafe
- Purposeful Reactive Programming
- Goal-C Interoperability
- Library & API Design
Swift is a wealthy language with a plethora of options to supply. Studying the official documentation or entry-level books is essential, but it surely’s not sufficient to know the true energy of the language.
Professional Swift is right here to assist, by exhibiting…
extra
This part tells you just a few issues you have to know earlier than you get began, equivalent to what you’ll want for {hardware} and software program, the place to seek out the undertaking information for this ebook, and extra.
The primary part of this ebook covers the fundamental constructing blocks of the Swift language: The kind system (enums, structs and lessons), Protocols and Generics. We’ll begin with a quick refresher of every matter after which leap proper into the behind-the-scenes implementations.
The content material of this part will expose the inside workings of the sort system, in addition to get you intimately acquainted with protocols and generics.
Welcome to Professional Swift. On this chapter, you’ll find out about a number of the motivations behind creating the Swift language, take a brief however deep dive into the Swift toolchain circulate and have a look at Swift. You’ll develop a easy language characteristic, ifelse, to discover a number of the services Swift affords for creating highly effective, expressive abstractions.
Varieties are important to constructing Swift applications. The Swift compiler kind checks your code to confirm correctness, guarantee security and allow larger optimization. You’ll achieve expertise concerning the totally different nominal varieties and mutation with a number of small examples. You’ll additionally implement mutable worth semantics for a QuadTree kind utilizing copy-on-write dynamic storage.
On this chapter you will undergo a quick refresher on the fundamentals of protocols in addition to a few of their extra not often used options.
You’ll additionally find out about frequent patterns that use protocols in addition to some helpful gotchas and edge instances to remember.
On this chapter, you will get intimately acquainted with generics by persevering with to work on the networking library you began within the earlier chapter. You may discover ways to write generic capabilities, lessons and structs; the right way to use protocols with related varieties; what kind erasure is and the right way to put all that collectively to make a coherent API.
This sections covers the bottom layer of writing Swift applications: Numerics, Ranges, Strings, Sequences, Collections, Codable and the much less apparent, however crucial matter – Unsafe.
As you’d anticipate from a sophisticated ebook, we don’t solely clarify these matters, but in addition examine how they’re constructed, how they’re represented, and the right way to use them successfully.
Swift is a platform-agnostic, general-purpose programming language that helps numerous numeric varieties with differing house, vary, accuracy and efficiency traits. Constructing two apps (BitViewer and Mandlebrot), you’ll see how Swift simplifies programming with protocols and generics. You’ll additionally have a look at vary varieties and the way operators and generics as soon as once more come to the rescue in implementing these language options.
Sequence, Assortment and associated protocols type the spine of the usual library for varieties like Array, Dictionary and Set. You’ll see how these protocols permit you to write generic algorithms that function throughout households of collections. The usual library affords some ways to shortly construct customized sequences and collections. You’ll use these to construct a number of examples together with a customized mutable assortment to implement Conway’s Sport of Life. You’ll additionally create a chunking algorithm that can be utilized with any assortment kind.
The right implementation of a string kind in Swift has been a controversial matter for fairly a while. The design is a fragile stability between Unicode correctness, encoding agnosticism, ease-of-use and high-performance. Nearly each main launch of Swift has refined the String kind to the superior design now we have at the moment. You’ll study how one can most successfully use strings, what they are surely, how they work and the way they’re represented.
When creating your app, you’ll typically take care of a myriad of information fashions and numerous exterior items of information that you just’ll wish to signify as knowledge fashions in your app.
On this chapter, you’ll shortly flick thru the fundamentals of Codable, after which give attention to the superior supplies down the darkish corners of codable varieties.
Swift is a memory-safe and type-safe language. In some instances, you would possibly want your code to be extraordinarily optimized, during which case the tiny overhead added by the security checks from Swift is perhaps too costly. You is perhaps coping with an enormous stream of real-time knowledge, manipulating giant information or different giant operations that take care of giant knowledge.
On this chapter you will discover ways to use unsafe Swift to straight entry reminiscence by means of quite a lot of pointer varieties and the right way to work together with the reminiscence system straight.
The ultimate part of this ebook covers superior strategies to super-charge your Swift powers, and use all of what Swift has to supply.
We’ll cowl matters like Greater order capabilities, Purposeful reactive programming, Goal-C interoperability, utilizing Instrumentation, and API design.
Greater-order capabilities can simplify your code considerably by making it extra readable, rather a lot shorter and simpler to reuse. You may study what are increased order capabilities, what’s currying and study examples of how they’re utilized in the usual library.
On this chapter you will study a very powerful and refined ideas of purposeful reactive programming and how one can apply these ideas to your apps.
Prefer it or not, Goal-C remains to be a closely used language in legacy codebases and apps which were in manufacturing for a few years. In your personal apps, you’ll typically have a large Goal-C codebase that simply doesn’t really feel at house inside your Swift code or wish to use a few of your shiny new Swift code in your Goal-C code.
On this chapter, you will discover ways to create a healthful expertise for customers of each the Goal-C and Swift parts of your codebase in a approach that feels as if it had been designed for both.
Being a terrific iOS software program engineer is not solely about being a grandmaster of the Swift language. It is also about understanding which instruments the platform places at your disposal, the right way to use them to sharpen your expertise and the right way to establish areas of enchancment in your code.
On this chapter you will find out about superior options of the Devices app, and the right way to use it to enhance your code.
Discover just a few matters to boost your skillset and instinct for designing nice APIs.
Subjects like Documentation, Encapsulation, versioning, and a number of other highly effective language options.