Now that Apple has officially released Xcode 6 and the NDA has been lifted, it's time to dive deeper into Swift—Apple's new language for building iOS apps. Learning how to properly use initializers in Swift can be daunting at first. Swift's requirement that all stored properties in a class are initialized adds complexity to the initialization process. In the first part of this two-part post I'm going to demystify initializers as I provide a hands-on approach to learning how to best implement initializers in your custom classes.
The word is out! The new Apple Watch is coming your way in early 2015, providing a brand new platform and great opportunities for a new category of apps. In this post I'll cover some of the basic features available for app developers so you can begin thinking about how these features can be put to use in your own custom apps.
The Swift programming language has a new feature called optionals that were not previously available in Objective-C. They are similar to optional types in Java and nullable types in the C# programming language.
Do you have an idea for an app but lack the programming knowledge to begin build it? In this weekly blog series, I will take you, the non-programmer, step by step through the process of creating apps for the iPhone, iPod touch, and iPad. Join me each week on this adventure, and you will experience how much fun turning your ideas into reality can be! This is Part 18 of the series. If you are just getting started now, check out the beginning of the series here. (This post has been updated to iOS 7.1.)
We've been discussing Core Data in my last several posts and now you should understand the basics of:
Even though Apple has provided the new Swift programming language for building iOS apps, one thing remains the same—we still use the Cocoa Touch Framework libraries to build iOS functionality into our apps. However, since the Cocoa Touch Framework is written in Objective-C, how is this accomplished? In this article I'll show you the mechanics behind how Swift accesses Objective-C code, and how the Cocoa Touch APIs (application programming interfaces) change when you access them from Swift.
In this post, I'm going to demonstrate some of the powerful new features of enumerations in Swift.
Declaring Swift Enumerations
Just about every programming language has the concept of enumerations. An enumeration allows you to group a set of related constants together. It contains a complete list of all the possible values for a given type.
As promised, here is my first installment on learning to program in the new Swift language!
Defining Classes in Swift
The following code shows an example of a Swift class definition:
To declare a class in Swift, you use the class keyword followed by the name of the class. If it has a superclass, you add a colon and the name of the superclass. The beginning and end of the class are indicated by the opening and closing curly braces.
Over the years I have literally taught tens of thousands of people how to write code in Objective-C through training classes, conferences, online forums, and my book series. Based on the mountain of feedback I have received, I can tell you some key points that make Swift much easier to learn than Objective-C.
If Objective-C is the only language you have ever coded in, I have one thing to say about moving to Swift. Welcome to the 21st century.
Apple, notorious for its secrecy, has loosened up its restrictive NDA (Non-Disclosure Agreement) for the beta versions of iOS 8, OS X, and Xcode 6. In the latest version of the iOS Developer Program License Agreement, they have added the following statement in the Confidentiality section under the topic 10.1 Information Deemed Apple Confidential:
So the word is out. iOS 8, Xcode 6 and the new Swift programming language are headed your way. What should you do? Should you continue to learn iOS 7 and Objective-C or should you make the switch to iOS 8 and Swift programming? I've already had several emails and tweets asking about this as iOS developers ponder this important question.