├── README.md
├── a-better-way-to-learn-swift.mdown
├── course.json
└── images
└── swift.jpg
/README.md:
--------------------------------------------------------------------------------
1 |
2 | A Better Way to Learn Swift
3 | =====
4 |
5 | Welcome to the "A Better Way to Learn Swift" Github repository. This tutorial is hosted by [Thinkster](https://thinkster.io/a-better-way-to-learn-swift).
6 |
7 | We'd like to make this a community maintained resource so if you have any improvements or fixes, feel free to open a pull request!
8 |
9 | 
A Better Way to Learn Swift by Thinkster is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
10 |
--------------------------------------------------------------------------------
/a-better-way-to-learn-swift.mdown:
--------------------------------------------------------------------------------
1 | [github link]: https://github.com/GoThinkster/swift
2 |
3 | [swiftcast tweet link]: https://twitter.com/intent/tweet?text=@SwiftCastTV%20@GoThinkster%20
4 |
5 | [apple_dev]: https://developer.apple.com/register/index.action
6 | [playgrounds]: https://developer.apple.com/library/ios/recipes/Playground_Help/Chapters/AboutPlaygrounds.html
7 |
8 | [chapter_tour]: https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html#//apple_ref/doc/uid/TP40014097-CH2-XID_1
9 | [chapter_basics]: https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html
10 | [optionals_basics]: https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5-XID_485
11 | [optionals_complete_guide]: http://matteomanferdini.com/the-complete-guide-to-understanding-swift-optionals/
12 | [chapter_extensions]: https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/Extensions.html#//apple_ref/doc/uid/TP40014097-CH24-XID_229
13 | [solutions]: http://www.swiftcast.tv/articles/swift-programming-language-solutions-experiments
14 | [swift_js]: http://realm.io/news/swift-for-javascript-developers/
15 | [operators]: http://nshipster.com/swift-operators/
16 | [reserved_words]: https://swiftcast.tv/articles/reserved-words-in-swift-and-how-to-escape-them
17 | [values_vs_reference]: https://developer.apple.com/swift/blog/?id=10
18 | [values_vs_reference_intuition]: http://www.objc.io/issue-16/swift-classes-vs-structs.html
19 | [compound_vs_named]: https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/Types.html
20 | [optionals_case]: https://developer.apple.com/swift/blog/?id=12
21 | [swift_defines_away]: https://medium.com/@rrridges/swift-optionals-a10dcfd8aab5
22 | [chapter_functions]: https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/Functions.html
23 | [chapter_closures]: https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/Closures.html
24 | [basic_functions_closures]: http://airspeedvelocity.net/2014/06/11/a-basic-tutorial-on-functions-and-closures-in-swift/
25 | [function_cheatsheet]: http://adoptioncurve.net/archives/2014/08/the-many-forms-of-swift-functions-a-cheatsheet/
26 | [closure_choke]: http://www.informit.com/articles/article.aspx?p=2234250
27 |
28 | [booleans]: http://www.swiftcast.tv/articles/54274a673033340002010000
29 | [numbers]: http://www.swiftcast.tv/articles/542754d93033340002020000
30 | [variables_constants]: http://www.swiftcast.tv/articles/54276cfe3033340002030000
31 | [strings]: http://www.swiftcast.tv/articles/542891c63033340002070000
32 | [strings_man]: http://www.swiftcast.tv/articles/542b65556335660002000000
33 | [floats_doubles]: http://www.youtube.com/watch?v=vql7qLixME4
34 | [arrays]: http://www.swiftcast.tv/articles/542b75436335660002010000
35 | [arrays_man]: http://www.swiftcast.tv/articles/542b851f6335660002020000
36 | [dict]: http://www.swiftcast.tv/articles/542b90996335660002030000
37 | [dict_man]: http://www.youtube.com/watch?v=M9sbLa2AsCM
38 | [extensions]: http://www.youtube.com/watch?v=rvKyeOqMldA
39 | [for]: http://www.youtube.com/watch?v=SHtzIdnG-PY
40 | [for_in]: http://www.youtube.com/watch?v=nPvNJANVM7o
41 | [while]: http://www.youtube.com/watch?v=Pc-SO4F2tjY
42 | [do_while]: http://www.youtube.com/watch?v=eDNB0AoLaMo
43 | [if]: http://www.youtube.com/watch?v=ZeksjlD-eCo
44 | [switch]: http://www.youtube.com/watch?v=R1sn8nhUNFc
45 | [optionals]: http://www.youtube.com/watch?v=6yJwBU1TYoQ
46 | [closures]: http://www.youtube.com/watch?v=3Ob6YG5FRHE
47 | [functions]: http://www.youtube.com/watch?v=ioR12RPBY0k
48 |
49 | [structs]: https://www.youtube.com/watch?v=8NSXdqwxRbE&index=3&list=PLfOZCUzRoPfKeOS_pwpiqbdviGcCOcTYb
50 | [enums]: https://www.youtube.com/watch?v=5nwgfpNkMJw&index=7&list=PLfOZCUzRoPfKeOS_pwpiqbdviGcCOcTYb
51 | [classes]: https://www.youtube.com/watch?v=2HwnLD0Xxro&index=4&list=PLfOZCUzRoPfKeOS_pwpiqbdviGcCOcTYb
52 | [protocols]: https://www.youtube.com/watch?v=KzypIO_QoMw&index=9&list=PLfOZCUzRoPfKeOS_pwpiqbdviGcCOcTYb
53 | [chapter_properties]: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Properties.html
54 | [chapter_methods]: https://developer.apple.com/library/prerelease/mac/documentation/Swift/Conceptual/Swift_Programming_Language/Methods.html
55 | [chapter_inheritance]: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Inheritance.html#//apple_ref/doc/uid/TP40014097
56 | [chapter_initializers]: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html#//apple_ref/doc/uid/TP40014097-CH18-XID_306
57 | [when_to_use_enums]: http://www.swift-studies.com/blog/2014/7/1/struct-enum-or-class
58 | [oop_functional]: http://www.swiftcast.tv/articles/oop-functional-swift
59 |
60 | [adam_quick]: http://vimeo.com/102163542
61 | [WWDC_testing]: https://developer.apple.com/videos/wwdc/2014/
62 |
63 | [xctest_reading]: http://www.swiftcast.tv/articles/introduction-to-xctest
64 | [unit_testing_reading]: https://bendyworks.com/unit-testing-in-swift/
65 | [tips_tricks]: http://natashatherobot.com/swift-unit-testing-tips-and-tricks/
66 | [nshipster_xctest]: http://nshipster.com/xctestcase/
67 | [async_unit_testing]: http://www.subfurther.com/blog/2014/07/16/asynchronous-unit-testing-in-swift-the-good-ugly-the-bad-and-the/
68 | [bad_testing]: http://www.objc.io/issue-15/bad-testing-practices.html
69 | [bdd_testing]: http://railsware.com/blog/2014/07/04/bdd-style-testing-in-swift-with-sleipnir/
70 |
71 | [sleiphinr_repo]: https://github.com/railsware/Sleipnir
72 | [quick_repo]: https://github.com/Quick/Quick
73 | [nilble_repo]: https://github.com/Quick/Nimble
74 |
75 | [sprite_intro]: http://www.swiftcast.tv/articles/introduction-to-sprite-kit
76 | [sprite_animation]: http://www.swiftcast.tv/articles/using-sprite-kit-to-animate-a-scene
77 | [sprite_physics]: http://www.swiftcast.tv/articles/getting-started-with-sprite-kit-physics
78 | [sprite_particles]: http://flexmonkey.blogspot.com/2014/07/using-swift-and-sprite-kit-for-physics.html
79 |
80 | [cheat_sheet]: http://www.swiftcast.tv/articles/cheat-sheets-for-swift
81 | [syntax_guide]: http://www.swiftcast.tv/articles/pro-tips-for-swift-syntax
82 |
83 |
84 | # Introduction
85 |
86 | No looking back now.
87 |
88 | You've come to this tutorial because you want to learn Swift, Apple's new
89 | programming language for making iOS and MacOS apps. This tutorial is bringing
90 | together various resources to swiftly (ha!) and thoroughly introduce each
91 | component of the Swift Programming Language.
92 |
93 | There was an initial frenzy of excitement around the new language in June when
94 | Apple introduced Swift at WWDC 2014. Since then, the various beta bugs and the
95 | fact that no devices supported apps built in Swift has led to a bit of a
96 | decline in Swift's popularity. Well Swift is now in release 1.0 and iOS8 will
97 | soon be in the hands of millions of developers and consumers alike. There has
98 | never been a better time to dive into Swift.
99 |
100 | {announcement}
101 | Looking to learn how to build a Swift app from the ground up? Check out the
102 | [Flourish Tutorial](https://thinkster.io/swift-ios-app/)!
103 |
104 |
105 |
106 | # A note on this tutorial
107 |
108 | Swift is in its infancy. This tutorial is going to evolve and change as we
109 | learn more about the language and the applications of the concepts we cover. We
110 | are also constantly looking for more and better resources for each topic. With
111 | that in mind, you can find the [raw markdown for this tutorial][github link]
112 | over at Github. If you find good Swift resources that aren't mentioned here,
113 | feel free to submit a pull request!
114 |
115 | We'd like to give a special thanks to the great folks over at
116 | [Swiftcast](http://www.swiftcast.tv/) for kick-starting this tutorial. If you
117 | have any questions or comments tweet them at
118 | [@SwiftCastTV][swiftcast tweet link]!
119 |
120 |
121 | ## Prerequisites
122 |
123 | To work through this tutorial you'll need a fully functioning Apple developer
124 | setup. This includes
125 |
126 |
127 | {x: running_osx}
128 | A mac running OSX Mavericks or Yosemite
129 |
130 | {x: apple_dev}
131 | An [Apple developer account][apple_dev]
132 |
133 | {x: copy_of_xcode}
134 | A copy of Xcode 6
135 |
136 | ## Resources
137 |
138 | We expect a plethora of learning resources to come out for Swift now that the
139 | language is out of beta. Luckily, many resources are already available and this
140 | heavily leverages the following (and they are all free!):
141 |
142 | * The Swift Programming Language ebook from Apple (also available on iBooks)
143 | * The MadApper Swift Video Series
144 | * The Skip Wilson Swift Video Series
145 |
146 | ## One Last Thing
147 |
148 | This entire tutorial can be done in a playground: an interactive environment
149 | that exists in xcode that allows you to code and receive immediate results from
150 | your code without having to compile an app. Before actually learning about
151 | Swift, learn how to create and navigate around playgrounds.
152 |
153 |
154 | {x: playgrounds}
155 | Read [Exploring and Evaluating Swift Code in a Playground][playgrounds]
156 |
157 |
158 | # Swift Basics
159 |
160 | Now you are going to dive into the language itself. The goal of this section is
161 | to get a handle on the syntax, operators, and data types in Swift.
162 |
163 | ## Swift Syntax
164 |
165 | When learning a new language syntax, it is recommended that you immediately
166 | start writing in the language as much as possible. Apple's "A Swift Tour"
167 | chapter of The Swift Programming Guide provides an overview of Swift Syntax
168 | as well as a set of "experiments", short exercises that let you write some
169 | Swift code focusing on a different aspect of the Swift Syntax.
170 |
171 |
172 | {x: variables_constants}
173 | [Variables and Constants][variables_constants]
174 |
175 | ### Readings
176 |
177 | Along with the experiments in the Swift ebook, we are including two blog posts
178 | about reserved words and operators that can serve as reference materials.
179 |
180 |
181 | {x: chapter_tour}
182 | Read the [A Swift Tour][chapter_tour] chapter in the Swift ebook and work through the experiments.
183 |
184 | {x: solutions}
185 | [Check your solutions to experiments][solutions] and make any corrections.
186 |
187 | {x: operators}
188 | Read [about Swift operators][operators]
189 |
190 | {x: reserved_words}
191 | Read [about Swift Reserved Words][reserved_words]. Don't worry about memorizing these, just be aware.
192 |
193 | {x: swift_js}
194 | Optional: [Swift for Javscript Developers][swift_js] - We know many of you are coming from Javascript. Once you look a the Swift syntax you're going to see some similarities, so it is worth it to view the video and blog post by JP Simard on Swift for Javascript developers. JP goes over the key differences between the two languages as well as some similarities.
195 |
196 | ## Swift Types
197 |
198 | If you've made it this far you've read that one of the good parts about Swift
199 | is that it is a type-safe language. Even without having any idea what that
200 | means, you can probably assume the section in this tutorial about types is
201 | important. For learning about types, the MadApper video series and Apple's
202 | documentation pair nicely. Types in Swift can be confusing because there are
203 | four categories of types: named types, compound types, value types, and
204 | reference types. Each type in Swift is a compound type or a named type as well
205 | as either a reference type or a value type. Confused yet? No worries, we'll
206 | sort all of this out.
207 |
208 | ### Pre-Readings
209 |
210 | For Types, do the readings first before watching the videos on the specific
211 | types.
212 |
213 |
214 | {x: values_vs_reference}
215 | [Value Types vs. Reference Types][values_vs_reference]
216 |
217 | {x: values_vs_reference_intuition}
218 | [Building Intuition for Value Types vs. Reference Types][values_vs_reference_intuition]
219 |
220 | {x: compound_vs_named}
221 | [Compound Types vs. Named Types][compound_vs_named]
222 |
223 | ### Videos
224 |
225 |
226 | {x: booleans}
227 | [Booleans][booleans]
228 |
229 | {x: strings}
230 | [Strings][strings]
231 |
232 | {x: strings_man}
233 | [String Manipulation][strings_man]
234 |
235 | {x: numbers}
236 | [Numbers: Integers, Floats, Doubles][numbers]
237 |
238 | {x: arrays}
239 | [Arrays][arrays]
240 |
241 | {x: arrays_man}
242 | [Array Manipulation][arrays_man]
243 |
244 | {x: dict}
245 | [Dictionaries][dict]
246 |
247 | {x: dict_man}
248 | [Dictionary Manipulation][dict_man]
249 |
250 |
251 | ## Extensions
252 |
253 | We can take all of our knowledge of the various data types in Swift and give
254 | them new functionality. Extensions allow us to give types new methods to suit
255 | the needs of our applications. For this, watch a long and awesome video on
256 | creating an extension and don't forget only named types can be extended.
257 |
258 |
259 | {x: extensions}
260 | [Extensions][extensions]
261 |
262 | ## Readings
263 |
264 |
265 | {x: chapter_extensions}
266 | Read the [Extensions][chapter_extensions] chapter in the Swift book.
267 |
268 |
269 | # Control Flow
270 |
271 | Okay now things get exciting. We are going to cover optionals, loops,
272 | functions, and closures. These concepts allow us to allow our code to do things
273 | only under certain conditions. Armed with this knowledge and what you've
274 | learned so far, you will be able to write code more concisely and you'll even
275 | be able to write the logic for basic games.
276 |
277 | ## Loops and Conditionals
278 |
279 | Control flow constructs in Swift allow us to iterate over collections, loop
280 | through a chunk of code multiple times, and execute code based on conditional
281 | statements. The MadApper series does a good job of covering these concepts
282 |
283 |
284 | {x: for}
285 | [For (condition, increment) Loops][for]
286 |
287 | {x: for_in}
288 | [For In Loops][for_in]
289 |
290 | {x: while}
291 | [While Loops][while]
292 |
293 | {x: do_while}
294 | [Do While Loops][do_while]
295 |
296 | {x: if}
297 | [If][if]
298 |
299 | {x: switch}
300 | [Switch][switch]
301 |
302 | ## Optionals
303 |
304 | Optional are a concept that is introduced in Swift and has no parallel in C or
305 | Objective-C. Using them effectively can prevent some common programming errors
306 | and increase the type safety of your code.
307 |
308 |
309 | {x: chapter_basics}
310 | [Optionals][chapter_basics]
311 |
312 | ### Readings
313 |
314 |
315 | {x: optionals_basics}
316 | Read the [section called "Optionals"][optionals_basics] in "The Basics Chapter" of the Swift ebook.
317 |
318 | {x: optionals_complete_guide}
319 | Read [The Complete Guide to Understanding Swift Optionals][optionals_complete_guide] to complete
320 | your understanding of optionals. Learn how they work under the hood, best pratices, and why we
321 | need them in the first place.
322 |
323 | {x: swift_defines_away}
324 | Read ["How Swift "Defines Away" Common Programming Errors…sort of"][swift_defines_away] by Matt Bridges
325 |
326 | {x: optionals_case}
327 | Read ["Optional Case Study: Value for Keys"][optionals_case] from the Swift Blog
328 |
329 | ## Functions and Closures
330 |
331 | Functions and Closures are self-contained blocks of code functionality. That is
332 | a vague explanation because functions and closures have very broad uses and can
333 | take many forms. For this section, jump in with two long (and excellent) video
334 | tutorials from Skip Wilson to get a practical crash course.
335 |
336 |
337 | {x: functions}
338 | [Functions][functions]
339 |
340 | {x: closures}
341 | [Closures][closures]
342 |
343 | Functions and closures can take many forms in Swift. The difference between a
344 | function and a closure can also be hard to grasp. The videos cover the
345 | basics, but these readings will give you a more complete understanding.
346 |
347 |
348 | {x: chapter_functions}
349 | Read [the Functions chapter][chapter_functions] in the Swift ebook.
350 |
351 | {x: chapter_closures}
352 | Read [the Closures chapter][chapter_closures] in the Swift ebook.
353 |
354 | {x: basic_functions_closures}
355 | Read [A Basic Tutorial on Functions and Closures in Swift][basic_functions_closures] for clarification on functions, closures, and closure expressions.
356 |
357 | {x: function_cheatsheet}
358 | For reference, read [The Many Forms of Swift Functions][function_cheatsheet] to see all of the various form functions can take in Swift.
359 |
360 | {x: closure_choke}
361 | Finally [Enough About Swift Closures to Choke a Horse][closure_choke] shows the flexibility of Swift in writing closures.
362 |
363 |
364 | # Object Oriented Programming
365 |
366 | Objective-C is an object-oriented programming language. Swift preserves many of
367 | the object-oriented ideas and constructs from Objective-C and you'll need to be
368 | comfortable with these concepts to write apps in Swift.
369 |
370 |
371 | {x: structs}
372 | [Structs][structs]
373 |
374 | {x: enums}
375 | [Enums][enums]
376 |
377 | {x: classes}
378 | [Classes][classes]
379 |
380 | {x: protocols}
381 | [Protocols][protocols]
382 |
383 | ## Readings
384 |
385 | Methods, Properties, and Initializers were covered in the videos, but the Swift
386 | ebook is a good place to get a detailed explanation of each of those ideas.
387 |
388 |
389 | {x: chapter_properties}
390 | [Properties][chapter_properties]
391 |
392 | {x: chapter_methods}
393 | [Methods][chapter_methods]
394 |
395 | {x: chapter_inheritance}
396 | [Inheritance][chapter_inheritance]
397 |
398 | {x: chapter_initializers}
399 | [Initializers][chapter_initializers]
400 |
401 | Now for a few practical readings on Swift objects
402 |
403 |
404 | {x: when_to_use_enums}
405 | [When to use Enums, Structs, and Classes][when_to_use_enums]
406 |
407 | {x: oop_functional}
408 | [OOP and Functional][oop_functional]
409 |
410 |
411 | # Testing
412 |
413 | Testing is important to driving the design of our applications, ensuring they
414 | behave as we expect, and documenting our code.
415 |
416 |
417 | {x: adam_quick}
418 | Watch [Adam Leonard's Swiftly Testing with Quick][adam_quick]
419 |
420 | {x: WWDC_testing}
421 | Watch [WWDC Testing in XCode 6][WWDC_testing]
422 |
423 | ## Readings
424 |
425 |
426 | {x: xctest}
427 | [Introduction to XCTest][xctest_reading]
428 |
429 | {x: unit_testing_reading}
430 | [Unit Testing in Swift][unit_testing_reading]
431 |
432 | {x: tips_tricks}
433 | [Swift Unit Testing Tips and Tricks][tips_tricks]
434 |
435 | {x: async_unit_testing}
436 | [XCTest][async_unit_testing]
437 |
438 | {x: async_unit_testing}
439 | [Asynchronous Unit Testing][async_unit_testing]
440 |
441 | {x: bad_testing}
442 | [Bad testing Practices][bad_testing]
443 |
444 | {x: bdd_testing}
445 | [BDD Style Testing with Slepnir][bdd_testing]
446 |
447 | ## Meet the Gang
448 |
449 | There is an array of libraries to use for testing. Whether your flavor is BDD
450 | or just plain old TDD there is something for everyone!
451 |
452 | * [Sleipinr][sleiphinr_repo] is a BDD style testing framework for Swift.
453 | * [Quick][quick_repo] is another BDD style testing framework for Swift.
454 | * [Nimble][nilble_repo] is a compliment to Quick. It's a Matchers framework.
455 |
456 |
457 | # SDK's
458 |
459 | When it comes to actually building apps in Swift, it is paramount to get an
460 | understanding of the various SDKs provided by Apple to get a sense for all of
461 | deep functionality that Apple provides for developers and to prevent yourself
462 | from trying to write code for functionality that already exists in an SDK or
463 | library. In fact, we recommend always looking for a trusted library before
464 | embarking on writing your own functionality (except, of course, if you're
465 | writing it yourself to better learn Swift).
466 |
467 | ## Sprite Kit
468 |
469 | Sprite Kit gives developers the ability to create simple or advanced 2D games
470 | by providing animation and physics functionality.
471 |
472 | ### Readings
473 |
474 | {x: sprite_intro}
475 | [Introduction to Sprite Kit][sprite_intro]
476 |
477 | {x: sprite_animation}
478 | [Sprite Kit Animation][sprite_animation]
479 |
480 | {x: sprite_physics}
481 | [Sprite Kit Physics][sprite_physics]
482 |
483 | {x: sprite_particles}
484 | [Sprite Kit Particles][sprite_particles]
485 |
486 |
487 | # Cheat Sheets
488 |
489 | Tools, tricks, and tips for both novice and senior Swift developers.
490 |
491 | ### Readings
492 |
493 | {x: cheat_sheet}
494 | [Master List of Swift Cheat Sheets][cheat_sheet] showcases a few cheat sheets for Swift.
495 |
496 | {x: syntax_guide}
497 | [Swift Syntax Guidelines][syntax_guide] is a best practices post in that is periodically updated as the language matures and best practices emerge.
498 |
499 |
--------------------------------------------------------------------------------
/course.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "A Better Way to Learn Swift",
3 | "description": "An introduction to the Swift programming language. Nail the basics of iOS programming with this free tutorial by Swiftcast.tv",
4 | "url": "a-better-way-to-learn-swift",
5 | "git": "https://github.com/GoThinkster/swift",
6 | "coverImage": "images/swift.jpg",
7 | "author": {
8 | "github": "swiftcast"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/images/swift.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gothinkster/swift/124c4323750e33e7357f96331d967ec5ec34296b/images/swift.jpg
--------------------------------------------------------------------------------