Open Xcode and create a new playground named BlastOff. Of course, the first thing you do is convince the team to use Swift. You’ve been tasked with designing the data model that will drive the launch sequence for the first manned mission to Mars, Mars Unum. Let’s set the scene: it’s your first day on your new job as a launch software engineer at NASA (go you!). If you need a refresher on the basics, or if you are just starting to learn Swift, check out our book Swift Apprentice or our many Swift intro tutorials. Also, make sure you have Xcode 8.0 or later installed. In Part 1, you’ll begin with the basics including structure initialization, and in Part 2 you’ll move on to learning about class initialization.īefore getting started, you should be familiar with the basics of initialization in Swift and be comfortable with concepts such as optional types, throwing and handling errors, and declaring default stored property values. There are a lot of rules, some of which are not obvious.īy following this two-part tutorial, you will learn the ins and outs to designing initializers for your Swift types. Because of the safety features built into Swift, initialization can be tricky. Initialization is the time to manage the inital values of stored properties for named types: classes, structures, and enumerations. Initialization in Swift is about what happens when you create a new instance of a named type: This tutorial combines all three for a combo-platter of awesomeness in which you’ll get to learn about the power of initialization! Some things are inherently awesome: rockets, missions to Mars, initialization in Swift. Update 11/4/16: This tutorial has been updated for Xcode 8 and Swift 3.
0 Comments
Leave a Reply. |