SlideShare a Scribd company logo
Swift 3 Fundamentals
iOS Workshops
Alberto Irurueta - Pia Muñoz
Overview
- Language Basics
- Playgrounds
- Variables
- Functions
- Optionals
- Control Flow
Language Basics
Language Overview
- No semicolons
print(“Hello world!”)
- Dot notation. No arrow operator (->).
obj1.use(obj2 and: obj3)
- C like comments (support for Javadoc like docs)
// /* */
Basic Types
- Int
- Long
- Float
- Double
- Character
- String
Others:
- Uint8, Int8, Uint16, Int16, Uint32, Int32, Uint64, Int64
Basic operators
- Operators are C like
- Sum: a + b, a += b
- Subtraction: a - b, a -= b
- Product: a * b, a *= b
- Division: a / b, a /= b
- Modulus: a % b, a %= b
- Booleans: a == b, a != b, a && b, a || b, !a
- Bitwise: a & b, a | b, a ^ b, ~a, a << 1, a >> 1
- Ternary: a > b ? a : b
- String concatenation: “hello” + “ world”
- String interpolation: “a + b is (a+b)”
Playgrounds
Playgrounds
- Is a simple way to learn and test pieces of code
- Perfect for newbies and students
- Available in:
- Xcode
- iPad as a standalone app
https://developer.apple.com/videos/play/wwdc2016/408/
Workhop iOS 1: Fundamentos de Swift
Workhop iOS 1: Fundamentos de Swift
Workhop iOS 1: Fundamentos de Swift
Hands on
Language Basics
Variables
Variables
Let (constants) vs. var (variables)
Variables
Goodbye nil!
Variables
Casting:
var decimal: Double = 12.5
var integer: Int = Int(decimal)
Inference:
let typeInferredDouble = 3.14159
let actuallyDouble2: Double = 3
let actuallyDouble = Double(3)
let actuallyDouble3 = 3 as Double
Variables
Arrays:
let emptyArray = [String]()
Dictionaries:
let emptyDictionary = [String: Float]()
Context
Instances only live within their context
{
var a = 1
{
var b = 2
print(“b is (b)”)
}
var b = 3
print(“b is (b)”)
}
Hands on
Variables
Functions
Functions
Functions are types!
Definition
func name(_ param: Int) -> Int {
...
}
Type
(Int) -> Int
Functions can have named parameters like objective C
Definition
func name(p param: Int) -> Int {
...
}
Type
(p: Int) -> Int
Functions
Functions
Functions can be nested
func func1() -> Void {
print(“func1”)
func func2(){
print(“func2”)
}
func2()
}
Functions
Sometimes you need to import
import UIKit
var a = max(1,2)
Hands on
Functions
Optionals
Optionals
Nil is not gone…
var a: Int?
var b: Int? = 3
var c: String? = nil
var d: String = “hello”
Providing default
let a: String? = nil
let b: String = “class”
let c = “Hi (a ?? b)”
let d = a!= nil ? a! : b
let e = a??b
Unwrapping optionals
Execution only when optional is defined
var a: String? = “hello”
if let b = a {
//a is defined
}
Chained evaluation
a?.someProperty?.someOtherProperty
Forced unwrapping
var b = a!.someProperty
Hands on
Optionals
Control Flow
Hands on
Control Flow
switch
switch variable {
case “var1”:
print(“variable is var1”)
case “var2”:
print(“variable is var2”)
default:
print(“variable is something else”)
}
for-in
for score in scores {
//Being scores an array
//And score each object in the array
}
for i in 0…<4 {
//It enters 4 times
//with values i = 0, 1, 2 and 3
}
while and repeat-while
while n < b {
n *= 2
}
repeat {
m *= 2
}while m < b
Workhop iOS 1: Fundamentos de Swift

More Related Content

PDF
Javascript good parts - for novice programmers
PPTX
Python The basics
PPT
Introduction to Python
PPT
JAVA Variables and Operators
PDF
Extending Python - EuroPython 2014
PPTX
Python programming
PDF
From 0 to mine sweeper in pyside
PDF
Haxe by sergei egorov
Javascript good parts - for novice programmers
Python The basics
Introduction to Python
JAVA Variables and Operators
Extending Python - EuroPython 2014
Python programming
From 0 to mine sweeper in pyside
Haxe by sergei egorov

What's hot (20)

PPT
Testing for share
PDF
AnyObject – 自分が見落としていた、基本の話
PDF
Fantom - Programming Language for JVM, CLR, and Javascript
PPTX
C sharp part 001
PDF
Java 8 Hipster slides
PPTX
C++11: Feel the New Language
PDF
Modern C++
PDF
Unmanaged Parallelization via P/Invoke
PPTX
PDF
Denis Lebedev, Swift
PDF
Iterator protocol
PPTX
C++ via C#
PPTX
Pointer and polymorphism
PDF
Functional Programming in PHP
PPT
pointers, virtual functions and polymorphisms in c++ || in cpp
PPTX
C# overview part 1
DOCX
C cheat sheet for varsity (extreme edition)
PPTX
Pointers,virtual functions and polymorphism cpp
PPT
Gentle introduction to modern C++
Testing for share
AnyObject – 自分が見落としていた、基本の話
Fantom - Programming Language for JVM, CLR, and Javascript
C sharp part 001
Java 8 Hipster slides
C++11: Feel the New Language
Modern C++
Unmanaged Parallelization via P/Invoke
Denis Lebedev, Swift
Iterator protocol
C++ via C#
Pointer and polymorphism
Functional Programming in PHP
pointers, virtual functions and polymorphisms in c++ || in cpp
C# overview part 1
C cheat sheet for varsity (extreme edition)
Pointers,virtual functions and polymorphism cpp
Gentle introduction to modern C++
Ad

Viewers also liked (20)

PDF
Workshop iOS 2: Swift - Structures
PDF
Workshop 24: React Native Introduction
PDF
Workshop 25: React Native - Components
PDF
Workshop 26: React Native - The Native Side
PDF
Workshop 21: React Router
PDF
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
PDF
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
PDF
Workshop 20: ReactJS Part II Flux Pattern & Redux
PDF
Workshop 23: ReactJS, React & Redux testing
PDF
Unlock The Value Of Your Microsoft and SAP Investments
PPTX
Change document display
PDF
Workshop 16: EmberJS Parte I
PDF
Workshop iOS 3: Testing, protocolos y extensiones
PPT
CDS Unit Testing
PDF
Workshop 11: Trendy web designs & prototyping
PDF
Workshop iOS 4: Closures, generics & operators
PDF
Multithreading 101
PDF
Hana sql
PDF
JavaScript for ABAP Programmers - 7/7 Functional Programming
PPT
Automated Testing Of Web Applications Using XML
Workshop iOS 2: Swift - Structures
Workshop 24: React Native Introduction
Workshop 25: React Native - Components
Workshop 26: React Native - The Native Side
Workshop 21: React Router
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 23: ReactJS, React & Redux testing
Unlock The Value Of Your Microsoft and SAP Investments
Change document display
Workshop 16: EmberJS Parte I
Workshop iOS 3: Testing, protocolos y extensiones
CDS Unit Testing
Workshop 11: Trendy web designs & prototyping
Workshop iOS 4: Closures, generics & operators
Multithreading 101
Hana sql
JavaScript for ABAP Programmers - 7/7 Functional Programming
Automated Testing Of Web Applications Using XML
Ad

Similar to Workhop iOS 1: Fundamentos de Swift (20)

PPTX
MODULE. .pptx
PPT
Python Programming Introduction demo.ppt
PDF
Workshop Swift
PPTX
Introduction to learn and Python Interpreter
PPTX
Python Training in Bangalore | Python Introduction Session | Learnbay
PPT
An Overview Of Python With Functional Programming
PPTX
Kotlin Basic & Android Programming
PPTX
Python language data types
PPTX
Python language data types
PPTX
Python language data types
PPTX
Python language data types
PPTX
Python language data types
PPTX
Python language data types
PPTX
Python language data types
PDF
10. funtions and closures IN SWIFT PROGRAMMING
PPS
C programming session 01
PPTX
Python Scipy Numpy
PPTX
Keep it Stupidly Simple Introduce Python
PDF
Funkcija, objekt, python
PDF
Introduction to Python Programming | InsideAIML
MODULE. .pptx
Python Programming Introduction demo.ppt
Workshop Swift
Introduction to learn and Python Interpreter
Python Training in Bangalore | Python Introduction Session | Learnbay
An Overview Of Python With Functional Programming
Kotlin Basic & Android Programming
Python language data types
Python language data types
Python language data types
Python language data types
Python language data types
Python language data types
Python language data types
10. funtions and closures IN SWIFT PROGRAMMING
C programming session 01
Python Scipy Numpy
Keep it Stupidly Simple Introduce Python
Funkcija, objekt, python
Introduction to Python Programming | InsideAIML

More from Visual Engineering (19)

PDF
Workshop 27: Isomorphic web apps with ReactJS
PDF
Workshop 22: ReactJS Redux Advanced
PDF
Workshop 22: React-Redux Middleware
PDF
Workshop 19: ReactJS Introduction
PDF
Workshop 18: CSS Animations & cool effects
PDF
Workshop 17: EmberJS parte II
PDF
Workshop 15: Ionic framework
PDF
Workshop 14: AngularJS Parte III
PDF
Workshop 13: AngularJS Parte II
PDF
Workshop 8: Templating: Handlebars, DustJS
PDF
Workshop 12: AngularJS Parte I
PDF
Workshop 10: ECMAScript 6
PDF
Workshop 9: BackboneJS y patrones MVC
PDF
Workshop 7: Single Page Applications
PDF
Workshop 6: Designer tools
PDF
Workshop 5: JavaScript testing
PDF
Workshop 4: NodeJS. Express Framework & MongoDB.
PDF
Workshop 3: JavaScript build tools
PDF
Workshop 2: JavaScript Design Patterns
Workshop 27: Isomorphic web apps with ReactJS
Workshop 22: ReactJS Redux Advanced
Workshop 22: React-Redux Middleware
Workshop 19: ReactJS Introduction
Workshop 18: CSS Animations & cool effects
Workshop 17: EmberJS parte II
Workshop 15: Ionic framework
Workshop 14: AngularJS Parte III
Workshop 13: AngularJS Parte II
Workshop 8: Templating: Handlebars, DustJS
Workshop 12: AngularJS Parte I
Workshop 10: ECMAScript 6
Workshop 9: BackboneJS y patrones MVC
Workshop 7: Single Page Applications
Workshop 6: Designer tools
Workshop 5: JavaScript testing
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 3: JavaScript build tools
Workshop 2: JavaScript Design Patterns

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
A Presentation on Artificial Intelligence
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Electronic commerce courselecture one. Pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPT
Teaching material agriculture food technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Approach and Philosophy of On baking technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Big Data Technologies - Introduction.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Per capita expenditure prediction using model stacking based on satellite ima...
A Presentation on Artificial Intelligence
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Electronic commerce courselecture one. Pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
cuic standard and advanced reporting.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Diabetes mellitus diagnosis method based random forest with bat algorithm
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Teaching material agriculture food technology
The AUB Centre for AI in Media Proposal.docx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Approach and Philosophy of On baking technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Empathic Computing: Creating Shared Understanding
Big Data Technologies - Introduction.pptx

Workhop iOS 1: Fundamentos de Swift