Introduction

Whether you’re a complete novice looking to get started in programming, someone familiar with programming but curious about learning more, or a seasoned programmer comfortable with other programming languages but unfamiliar with Macintosh programming, this book is for you. Whatever your skill level, this book will help everyone understand how to use Apple’s latest programming language, Swift, to create OS X programs for the Macintosh.

Now you may be wondering why learn Swift and why program for the Macintosh? The answer is simple.

First, Swift is Apple’s newest programming language designed to make creating OS X and iOS programs faster, easier, and more reliable than before. Previously, you had to use Objective-C to create OS X and iOS apps. While powerful, Objective-C is much harder to learn; more complicated to read and write; and because of its complexity, more prone to introducing errors or bugs in a program.

On the other hand, Swift is just as powerful as Objective-C (actually more powerful as you’ll soon see), far easier to learn, and much simpler to read and write while also minimizing common programming errors at the same time. Swift gives you all the benefits of Objective-C with none of the drawbacks. Plus Swift gives you features that Objective-C doesn’t offer, which makes Swift a far better programming language to learn and use today and tomorrow. Since Swift is Apple’s official programming language, you can be certain learning Swift will lead to greater opportunities now and long into the future.

Second, you may wonder why learn to create Macintosh programs? After all, the hot trend is learning to create iOS apps for the iPhone, iPad, and Apple Watch. If you plan on developing software, you definitely want to use Swift to create iOS apps.

However, learning Swift means understanding the following:

  • The principles of programming and object-oriented programming in particular
  • The syntax of the Swift programming language
  • Xcode’s features
  • Apple’s software development framework (called Cocoa) that forms the foundation of every OS X and iOS program
  • The principles of user interface design

Does this sound like a lot to learn? Don’t worry. We’ll go through each process step by step so you won’t feel lost. The point is that to create OS X programs and iOS apps, you need to learn multiple topics, but creating iOS apps poses an additional challenge.

For example, an iOS app needs to respond to touch gestures with one finger, two fingers, swipes, shakes, and motion in addition to adapting to changes when the user flips an iPhone or iPad left, right, upside down, or right side up.

In comparison, a Macintosh program only needs to respond to keyboard and mouse input. That means OS X programs are much simpler to create and understand, which also means that learning Swift to create OS X programs is far easier than learning Swift to create iOS apps.

Best of all, the principles are exactly the same. What you learn creating OS X programs are the exact same skills you need to create iOS apps. The difference is that creating OS X programs is far easier, less confusing, and much less intimidating than creating iOS apps.

Trying to create iOS apps right from the start can be like trying to swim across the English Channel before you even know how to hold your breath underwater.

You don’t want to frustrate yourself unnecessarily. That’s why it’s much easier to learn the principles of iOS app programming by first learning OS X programming. Once you’re familiar with OS X programming, you’ll find it’s trivial to transfer your programming skills to creating iOS apps. By learning to create OS X programs in Swift, you’ll learn everything you need to know to eventually create iOS apps in Swift, plus you’ll know how to create OS X programs so you can tap into the growing Macintosh market as well.

Following Lucrative Programming Trends

The introduction of a new computer platform has always ushered in a lucrative period for programmers. In the early 80s, the hottest platform was the Apple II computer. If you wanted to make money writing programs, you wrote programs to sell to Apple II computer owners, such as Dan Bricklin did, an MBA graduate student at the time, when he wrote the first spreadsheet program, VisiCalc.

Then the next big computing platform shift occurred in the mid-80s with the IBM PC and MS-DOS. People made fortunes off the IBM PC including Bill Gates and Microsoft, which went from a small, startup company to the most dominant computer company in the world. The IBM PC made millionaires out of hundreds of people including Scott Cook, a former marketing director at Proctor & Gamble, who developed the popular money manager program, Quicken.

Microsoft helped usher in the next computer platform when they shifted from MS-DOS to Windows and put a friendly graphical user interface on IBM PCs. Once again, programming Windows became the number one way that programmers and non-programmers alike made fortunes by writing and selling their own Windows programs. Microsoft took advantage of the shift to Windows by releasing several Windows-only programs that have become fixtures of the business world such as Outlook, Access, and Excel.

Now the world is shifting toward the new computer platform of Apple products running OS X and iOS. Thousands of people, just like you, are eager to start writing programs to take advantage of the Macintosh’s rising market share along with the dominant position of the iPhone and the iPad in the smart phone and tablet categories, and the Apple Watch in the wearable computer market.

Besides experienced developers, amateurs, hobbyists, and professionals in other fields are also interested in writing their own games, utilities, and business software specific to their particular niche.

Many programmers have gone from knowing nothing about programming to earning thousands of dollars a day by creating iPhone/iPad apps or Macintosh programs. As the Macintosh, iPhone, iPad, and now the Apple Watch continue gaining market share all over the world, more people will use one or more of these products, increasing the potential market for you.

All this means is that it’s a perfect time for you to start learning how to program your Macintosh right now because the sooner you understand the basics of Macintosh programming, the sooner you can start creating your own Macintosh programs along with iPhone/iPad/Apple Watch apps.

What to Expect From This Book

Whether you’re a complete novice or a seasoned programmer coming from another programming environment, this book will minimize technical jargon and focus on helping you understand what to do and why.

If you just want to get started and learn the basics of programming in Swift, this book is for you. If you’re already an experienced Windows programmer and want to get started programming the Macintosh, this book can be especially helpful in teaching you the basics in a hurry.

If you’ve never programmed before in your life, or if you’re already familiar with programming but not with Macintosh programming, then this book is for you. Even if you’re experienced with Macintosh programming, you may still find this book handy as a reference to help you achieve certain results without having to wade through several books to find an answer.

You won’t learn everything you need to create your own super-sophisticated programs, but you’ll learn just enough to get started, feel comfortable using Xcode, and be able to tackle other programming books with more confidence and understanding. Fair enough? If so, then turn the page and let’s get started.

 Note  All code in this book was tested using Swift 2 in Xcode 7. If you’re using Xcode 6, some features in this book won’t work.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset