Book Image

Mastering macOS Programming.

By : Stuart Grimshaw, Gregory Casamento
Book Image

Mastering macOS Programming.

By: Stuart Grimshaw, Gregory Casamento

Overview of this book

macOS continues to lead the way in desktop operating systems, with its tight integration across the Apple ecosystem of platforms and devices. With this book, you will get an in-depth knowledge of working on macOS, enabling you to unleash the full potential of the latest version using Swift 3 to build applications. This book will help you broaden your horizons by taking your programming skills to next level. The initial chapters will show you all about the environment that surrounds a developer at the start of a project. It introduces you to the new features that Swift 3 and Xcode 8 offers and also covers the common design patterns that you need to know for planning anything more than trivial projects. You will then learn the advanced Swift programming concepts, including memory management, generics, protocol orientated and functional programming and with this knowledge you will be able to tackle the next several chapters that deal with Apple’s own Cocoa frameworks. It also covers AppKit, Foundation, and Core Data in detail which is a part of the Cocoa umbrella framework. The rest of the book will cover the challenges posed by asynchronous programming, error handling, debugging, and many other areas that are an indispensable part of producing software in a professional environment. By the end of this book, you will be well acquainted with Swift, Cocoa, and AppKit, as well as a plethora of other essential tools, and you will be ready to tackle much more complex and advanced software projects.
Table of Contents (28 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Dedication
Preface
18
LLDB and the Command Line

What you'll get from this book


This brings us quite nicely to the goals of this book.

Well, in a general sense, its goal is to help you reach yours, of course. But how exactly are we going to do that?

The focus of this book is very much on real-world programming skills and best practices, with a clear preference for techniques that provide solid, maintainable code over a long app lifetime, as opposed to the latest Thing from the developer conferences. Similarly, we will concentrate more on the functional interior of the code rather than short-lived user-interface design trends that will be of little interest a year from now.

There is also a strong emphasis on developing the skills that a developer will need when working in the industry, within a team that may include other developers, including those working on different platforms, as well as graphic artists, technical leads, project and product managers, system administrators and back-end developers, and any number of other roles with which it is necessary to communicate with clarity and accuracy. These people will have their own corners of the business to attend to, to which you will frequently have to adapt your work, making it all the more important that you have a number of tools at your disposal to deal with rapidly changing requirements and priorities.

Frequently, it is necessary to include third-party frameworks and libraries, often ones that you would not choose yourself: maybe because the team has been using them within a project already; maybe because a client has requested the addition of an analytics engine to an app, or to add functionality to an app not available natively. These are perhaps the most common reasons, but they are not the only ones, and an ability to integrate these resources into your work is an essential part of modern app development, and one that is only likely to increase with time.

Professional coding means writing clear code, adhering where appropriate (which means most of the time) to established practices. We will prefer simplicity over cleverness every time, and hopefully this is a habit you will develop yourself.

Note

Write every line of code for somebody else. That may mean someone else in your team, or it might mean your successor when you move on. It will frequently mean yourself in a year's time--which is when you'll be most glad you wrote logical, well-structured code.

A huge part of coding wisely means knowing which techniques to deploy, and which are better left out, in any given situation. It means learning to strike the right balance between clarity and the inevitable complexity that results from the growth of a project over time.

You will also learn to deal with version control safely, an essential part of working on larger projects, even as a sole developer.

Debugging your code is an essential part of programming, and we will look at the tools available to you in Xcode to make these tasks easier, faster, and safer. Fixing bugs can become a major part of your work, and your skills in this area will contribute greatly to your ability to deliver reliable code.

Finally, we will not shy away from references to resources beyond this book. The time is long gone when a developer can be expected to know every detail of a language or platform, and knowing where to search for documentation and help is an indispensable part of our work as developers. It has been said that a good developer spends two thirds of the time reading and one third coding. Although that should perhaps be taken with a pinch of salt, if only because it overlooks writing documentation, testing, and talking to clients, managers, and team members, it nevertheless makes clear that writing code is not only not everything, it's not even most of it.

Our highest priority is to impart knowledge that will be immediately and enduringly useful to you as a developer. That may seem like stating the obvious, but you will notice that the content of this book does not necessarily reflect the buzz and hype around the blogosphere's latest shiny new toys. It is true that even the oldest, best-tested tools were new once, but it is not our intention here to get lost in the esoteric delights of functional programming, protocol-oriented programming, reactive programming, or whatever else is the subject of heated debate at the time of writing.

That is not to say that such topics are somehow not thrilling, valuable, and thought-provoking. They most definitely are, but they are not within the scope of this book. However, the website is not limited in size, so we'll see what we can do.

Also not covered here is the migration and adaptation of Swift 2 code to Swift 3. There will doubtless be any number of articles out there covering this, but for the purposes of this book, we will treat Swift 3 as the only version of interest. And although it's an important topic, moving from Objective C to Swift is beyond the scope of this book.

Finally, we will not cover unit tests and integration testing. This field is a wide one, space here is limited, and the reader is encouraged to find resources that can do justice to both the topic itself, and the wide range of opinions surrounding it.