Swift Programming Language
Cihad Horuzoglu
Swift Overview
● Apple’s new programming language
● Write apps for iOS, Mac, watchOS,
tvOS, etc.
● Open source!
● Works with C and Objective-C
● Type Safety
● Modern Language
Playgrounds
How works Playground
IBM Bluemix Swift
Data Types
● Integers: 0, 1, 2, 42, 31337, -10
● String: “Kermit”, “Gonzo”, “Ms. Piggy”
● Double: 1.5, 3.14159, 81.2, 578.238
● Boolean: true, false
Variables
Constants
Comparison & Booleans
For Loops
Scope
“age” is available for entire scope
“myString” is available just in “for” scope
Functions
Default Arguments
Optionals
Struct vs. Class
Struct: Class:
Struct
Struct: Methods
Struct: Property Mutability
Struct: Instance Mutability
Struct: Properties
Class
● Similar features with
structs
○ Properties
○ Methods
● Need to write initializers
yourself
Arrays
Sets
Dictionaries
Enumerations
An enumeration defines a common type for a
group of related values and enables you to work
with those values in a type-safe way within your
code.
Features
● Method
● Computed Properties
Protocol
Stored Properties
Computed Properties
Property Access
Properties Sample
Stored Property
Computed Property
Extensions
Safe Unwrapping
Example
“ is ” keyword
Errors
Throwing Errors Handling Errors
Reference Counting
De-initializers
Resources
● https://github.com/swifteducation
● https://itunes.apple.com/us/book/swift-programming-
language/id881256329?mt=11
● https://thinkster.io/a-better-way-to-learn-swift
● https://github.com/hsavit1/Awesome-Swift-Education
● https://www.hackingwithswift.com/
Thank You!
@cihadhoruzoglu