SlideShare uma empresa Scribd logo
1 de 72
1
Introduction of Swift
Presenter: Waseem Ahmad, Mindfire Solutions
Date: 28/10/2014
What you will learn
Presenter: Waseem Ahmad, Mindfire Solutions
What is Swift?
Variable
Constants
Type Inference
Type Aliases
String/Character Interpolation
Array and Dictionary
Loops
Optionals, Unwrapping an Optional
Functions
Tuples
Classes
Properties
Closures
Q & A
What is Swift ?
• Swift is Apple’s modern, type-safe language for Cocoa development that
builds on the best of C and Objective-C
• Safe
• Modern
• Power
Presenter: Waseem Ahmad, Mindfire Solutions
Variables
var variableName : String = “Swift”
var version: Double = 1.0
var day: Int = 28
var isAnimated: Bool = true
Presenter: Waseem Ahmad, Mindfire Solutions
Constants &Variables
let variableName: String = “Swift”
var version: Double = 1.0
var day: Int = 28
var isAnimated: Bool = true
Pretty clear which is constant and mutable, it’s define safe code in multithreaded
environment. Make code more clear and readable.
Presenter: Waseem Ahmad, Mindfire Solutions
Constants &Variables
let variableName: String = “Swift”
var version: Double = 1.0
let day: Int = 28
let isAnimated: Bool = true
Presenter: Waseem Ahmad, Mindfire Solutions
Type Inference
let variableName = “Swift” // As String
var version = 1.0 // As Double/Float
let day = 28 // As Int
let isAnimated = true // As Boolean
Code safe, these are valuable & constant explicitly type.
Presenter: Waseem Ahmad, Mindfire Solutions
Type Aliases
An alternative name for an existing type.
typealias AudioSample = UInt16
var maxAmplitudeFound = AudioSample.min
Presenter: Waseem Ahmad, Mindfire Solutions
Unicode Names
let variableName = “Swift” // As String
var version = 1.0 // As Double/Float
let day = 28 // As Int
let isAnimated = true // As Boolean
let π = 3.1415927
let � = "emoji"�
Presenter: Waseem Ahmad, Mindfire Solutions
String
var studentName: String = “Waseem”
var studentName = “Waseem” // Inferred to be of type string
Presenter: Waseem Ahmad, Mindfire Solutions
String
var studentName: String = “Waseem”
var studentName = “Waseem” // Inferred to be of type string
var documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
documentsPath = documentsPath.stringByAppendingString(subpath)
Presenter: Waseem Ahmad, Mindfire Solutions
Character
let studentName = “Waseem"
for character in studentName {
println(character)
}
W
a
s
e
e
m
Presenter: Waseem Ahmad, Mindfire Solutions
Complex String
var name = “Waseem”
var coins = 100
Congratulations, Waseem won 100 coins.
Presenter: Waseem Ahmad, Mindfire Solutions
String Interpolation
var name = “Waseem”
var coins = 100
Congratulations, Waseem won 100 coins.
let message = “Congratulations, (name) won (coins)”.
Presenter: Waseem Ahmad, Mindfire Solutions
String Mutability
var variableString = "Mindfire"
Presenter: Waseem Ahmad, Mindfire Solutions
String Mutability
var variableString = “Mindfire"
variableString += " Solutions”
// variableString is now “Mindfire Solutions"
Presenter: Waseem Ahmad, Mindfire Solutions
String Mutability
var variableString = “Mindfire"
variableString += " Solutions”
// variableString is now “Mindfire Solutions"
let constantString = “Mindfire"
constantString += " Solutions”
// error - constantString cannot be changed
Presenter: Waseem Ahmad, Mindfire Solutions
String Mutability
var variableString = “Mindfire"
variableString += " Solutions”
// variableString is now “Mindfire Solutions"
let constantString = “Mindfire"
constantString += " Solutions”
// error - constantString cannot be changed
Presenter: Waseem Ahmad, Mindfire Solutions
Collection Type (Array &
Dictionary)
Presenter: Waseem Ahmad, Mindfire Solutions
Array and Dictionary Literals
var names = [“John”, “Bob”, "Brian", "Jack"]
Presenter: Waseem Ahmad, Mindfire Solutions
Array and Dictionary Literals
var names = [“John”, “Bob”, "Brian", “Jack"]
var numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4]
Presenter: Waseem Ahmad, Mindfire Solutions
Difference Between NSArray &
NSDictionary
- It could work with any type (String, Int etc)
- Collection are typed collection
Presenter: Waseem Ahmad, Mindfire Solutions
Typed Collection
var names = [“John”, “Bob”, "Brian", “Jack”, 123]
var names = [“John”, “Bob”, "Brian", “Jack”, function()]
Presenter: Waseem Ahmad, Mindfire Solutions
Typed Collection
var names: String[] = [“John”, “Bob”, "Brian", “Jack”]
Presenter: Waseem Ahmad, Mindfire Solutions
Typed Collection
var names = [“John”, “Bob”, "Brian", “Jack”]
// An array of String Values
var numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4]
// An Dictionary With String Keys and Int Values
Typed collection made your code safe, you well know what you are retrieving and
adding.
Presenter: Waseem Ahmad, Mindfire Solutions
Loop
while !isTrue {
print(“hello”)
}
for var i = 1; i <= 13; ++i {
print(“hello”)
}
Presenter: Waseem Ahmad, Mindfire Solutions
For-In: Strings and Characters
let studentName = “Waseem"
for character in studentName {
println(character)
}
W
a
s
e
e
m
Swift Power, we can use character & emoji in similar way.
Presenter: Waseem Ahmad, Mindfire Solutions
For-In: Ranges
for number in 1...5 { // Clause Range
println("(number) times 4 is (number * 4)")
}
1 times 4 is 4
2 times 4 is 8
3 times 4 is 12
4 times 4 is 16
5 times 4 is 20
Presenter: Waseem Ahmad, Mindfire Solutions
For-In: Ranges
for number in 0..5 { // half clause range
println("(number) times 4 is (number * 4)")
}
0 times 4 is 0
1 times 4 is 4
2 times 4 is 8
3 times 4 is 12
4 times 4 is 16
Presenter: Waseem Ahmad, Mindfire Solutions
For-In: Array
var names = [“John”, “Bob”, "Brian", "Jack"]
for name in names {
println("Hello (name)")
}
Presenter: Waseem Ahmad, Mindfire Solutions
For-In: Dictionaries
let numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4]
!
for (animalName, legCount) in numberOfLegs {
println("(animalName)s have (legCount) legs")
}
ants have 6 legs
Power of swift extracting key and value in single loop, grouping of value is a power
full feature of swift i.e Tuples
Presenter: Waseem Ahmad, Mindfire Solutions
Modification in Array
var shoppingList = ["Eggs", "Milk"]
println(shoppingList[0])
Presenter: Waseem Ahmad, Mindfire Solutions
Modification in Array
var shoppingList = ["Eggs", "Milk"]
println(shoppingList[0])
shoppingList += "Flour"
shoppingList += ["Cheese", "Butter", "Chocolate Spread"]
Presenter: Waseem Ahmad, Mindfire Solutions
Modification in Array
var shoppingList = ["Eggs", "Milk"]
shoppingList += "Flour"
shoppingList += ["Cheese", "Butter", "Chocolate Spread”]
shoppingList[0] = "Six eggs"
Presenter: Waseem Ahmad, Mindfire Solutions
Modification in Array
var shoppingList = ["Eggs", "Milk"]
shoppingList += "Flour"
shoppingList += ["Cheese", "Butter", "Chocolate Spread”]
shoppingList[0] = "Six eggs”
["Six eggs", "Milk", "Flour", "Cheese", "Butter",
"Chocolate Spread"]
shoppingList[3...5] = ["Bananas", “Apples"]
["Six eggs", "Milk", "Flour", "Bananas", “Apples"]
Presenter: Waseem Ahmad, Mindfire Solutions
Modification in Dictionary
var numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4]
numberOfLegs["spider"] = 273
Presenter: Waseem Ahmad, Mindfire Solutions
Modification in Dictionary
var numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4]
numberOfLegs["spider"] = 273
numberOfLegs["spider"] = 8
What happen if we try to fetch a value that doesn’t have in array and dictionary?
let lionLegCount = numberOfLegs[“lion”] // Nothing at all :)
Presenter: Waseem Ahmad, Mindfire Solutions
Optional
var numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4]
let lionLegCount: Int? = numberOfLegs["lion"]
Presenter: Waseem Ahmad, Mindfire Solutions
Optional
var numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4]
let lionLegCount: Int? = numberOfLegs[“lion"]
if lionLegCount == nil {
println("Lion wasn't found")
} else {
let legCount = lionLegCount! // unwrapping of optional value
println("An lion has (legCount) legs")
}
Presenter: Waseem Ahmad, Mindfire Solutions
Optional
if numberOfLegs {
let legCount = numberOfLegs!
println("An Lion has (legCount) legs")
}
Presenter: Waseem Ahmad, Mindfire Solutions
Unwrapping an Optional
if let legCount = numberOfLegs {
println("An Lion has (legCount) legs")
}
Note:- Braces are required with If :)
Presenter: Waseem Ahmad, Mindfire Solutions
Switch
switch legCount {
case 0:
println("It slithers and slides around”)
case 1:
println("It hops")
default:
println("It walks")
}
Presenter: Waseem Ahmad, Mindfire Solutions
Switch
switch sender {
case executeButton:
println("You tapped the Execute button")
case firstNameTextField:
println("You tapped the First Name text field")
default:
println("You tapped some other object")
}
Presenter: Waseem Ahmad, Mindfire Solutions
Switch
switch legCount {
case 0:
println("It slithers and slides around")!
case 1, 3, 5, 7, 9, 11, 13:
println("It limps")
case 2, 4, 6, 8, 10, 12, 14:
println("It walks")
}
// error: switch must be exhaustive
Presenter: Waseem Ahmad, Mindfire Solutions
Switch
switch legCount {
case 0:
println("It slithers and slides around")!
case 1, 3, 5, 7, 9, 11, 13:
println("It limps")
case 2, 4, 6, 8, 10, 12, 14:
println("It walks”)
default:
println("It walks")
}
Presenter: Waseem Ahmad, Mindfire Solutions
Matching Value Ranges
switch legCount {
case 0:
println("It slithers and slides around")!
case 1…8:
println("It has few lags")
default:
println("It walks")
}
Presenter: Waseem Ahmad, Mindfire Solutions
Functions
func sayHello() {
println("Hello!")
}
Presenter: Waseem Ahmad, Mindfire Solutions
Functions with Parameters
func sayHello(name: String) {
println("Hello (name)!")
}
Presenter: Waseem Ahmad, Mindfire Solutions
Default Parameter Values
func sayHello(name: String = "World") {
println("Hello (name)!")
}
sayHello() // Hello World
sayHello(“Team”) // Hello Team
Presenter: Waseem Ahmad, Mindfire Solutions
Returning Values
func greetingMsg(name: String = "World") -> String {
return "Hello " + name
}
let greeting = greetingMsg()
Presenter: Waseem Ahmad, Mindfire Solutions
Returning Multiple Values
func getUsernInfo() -> (Int, String) {
return (25, “John”)
}
Presenter: Waseem Ahmad, Mindfire Solutions
Tuples
-Grouping a values
-Value could be any type
(3.79, 3.99, 4.19) // (Double, Double, Double)
(404, "Not found")
(2, "banana", 0.72)
-Tuple is not an replacement of structure but this is best when needs to
return multiple values like from function
func getUsernInfo() -> (Int, String) {
return (25, “John”)
}
Presenter: Waseem Ahmad, Mindfire Solutions
Decomposing of Tuples
func getUsernInfo() -> (Int, String) {
return (25, “John”)
}
let (age, name) = getUsernInfo()
println(“This is (name) and my age is (age)")
Presenter: Waseem Ahmad, Mindfire Solutions
Decomposing of Tuples
func getUsernInfo() -> (Int, String) {
return (25, “John”)
}
let (age, name) = getUsernInfo()
let (age: Int, name: String) = getUsernInfo()
println(“This is (name) and my age is (age)")
If you only need some of the tuple’s values, ignore parts of the tuple with an
underscore (_) when you decompose the tuple:
let (age, _) = getUsernInfo()
Presenter: Waseem Ahmad, Mindfire Solutions
Named Values in a Tuple
func getUsernInfo() -> (age: Int, name: String) {
return (25, “John”)
}
let userInfo = getUsernInfo()
println(“This is (userInfo.name) and my age is (userInfo.age)”)
Presenter: Waseem Ahmad, Mindfire Solutions
Classes
class Student {
// properties
// methods
// initializers
}
class Student: NSObject { // no need to derive a class with base as NSObject
}
We can create a subclass and inherited
class Medical: Student {
}
Presenter: Waseem Ahmad, Mindfire Solutions
Properties
class Student {
var rollNo = 1
var name: String?
// methods
// initializers
}
The big difference between objective c and swift is “no difference between Instance
variable and priorities”.
Here rollNo we can say as stored properties.
Presenter: Waseem Ahmad, Mindfire Solutions
Computed Properties
class Student {
var rollNo = 1
var name: String?
var description: String {
get {
return “Hi this (name!) and my roll number is (rollNo)“
}
}
}
Presenter: Waseem Ahmad, Mindfire Solutions
Computed Properties (RW)
class Student {
var rollNo = 1
var name: String?
var description: String {
get {
return “Hi this (name!) and my roll number is (rollNo)“
}
set {
}
}
}
Presenter: Waseem Ahmad, Mindfire Solutions
Computed Properties (Read)
class Student {
var rollNo = 1
var name: String?
var description: String {
return “Hi this (name!) and my roll number is (rollNo)“
}
}
Presenter: Waseem Ahmad, Mindfire Solutions
Initializer Class Syntax
class Student {
var rollNo = 1
var name: String?
var description: String {
return “Hi this (name!) and my roll number is (rollNo)“
}
}
let studentObj = Student()
println(studentObj.description)
- Automatic memory allocation
-No need to write type as Swift support Type Inference
let studentObj : Student = Student()
Presenter: Waseem Ahmad, Mindfire Solutions
Initializer Class Syntax
class Student {
var rollNo = 1
var name: String?
init() { // constructor
string = “Waseem”
}
var description: String {
return “Hi this (name!) and my roll number is (rollNo)“
}
}
Presenter: Waseem Ahmad, Mindfire Solutions
Overriding a Property
class Medical: Student {
init() {
super.init()
}
override var description: String { // Safe
return super.description + ", student of Medical"
}
}
Presenter: Waseem Ahmad, Mindfire Solutions
Property Observers
class Loan: Bank {
override var intrest: Double {
willSet {
// newValue is available here
if intrest > 10.0 {
// calculate // trigger
}
}
}
didSet {
// oldValue is available here
}
}
}
Presenter: Waseem Ahmad, Mindfire Solutions
Methods
class Student {
var rollNo = 1
var name: String?
func studentName(nameStr: String) {
name = nameStr
}
}
Presenter: Waseem Ahmad, Mindfire Solutions
Class Methods
class func isFileExistAtPath(filePath: NSString) -> Bool {
let filemanager = NSFileManager.defaultManager()
return filemanager.fileExistsAtPath(filePath)
}
Presenter: Waseem Ahmad, Mindfire Solutions
Class De-initialisation
class Student {
var rollNo = 1
var name: String?
init() { // constructor
fileOpen() //
}
deinit { // constructor
closeFile() //
}
}
Presenter: Waseem Ahmad, Mindfire Solutions
iPhone App to Advertise
Real Estate
Case Study
www.mindfiresolutions.com
Next Seminar: Swift in depth
Closures
Structures
Enum
Extensions
Memory Management
Optional Chaining
Generic type
Presenter: Waseem Ahmad, Mindfire Solutions
References
- Apple WWDC 2014
- Apple Inc. “The Swift Programming Language.” iBooks.
Presenter: Waseem Ahmad, Mindfire Solutions
Presenter: Waseem Ahmad, Mindfire Solutions
Question and Answer
Thank you
Presenter: Waseem Ahmad, Mindfire Solutions

Mais conteúdo relacionado

Semelhante a Swift-Programming Part 1

NUS iOS Swift Talk
NUS iOS Swift TalkNUS iOS Swift Talk
NUS iOS Swift TalkGabriel Lim
 
An Introduction to Scala (2014)
An Introduction to Scala (2014)An Introduction to Scala (2014)
An Introduction to Scala (2014)William Narmontas
 
Why Scala is the better Java
Why Scala is the better JavaWhy Scala is the better Java
Why Scala is the better JavaThomas Kaiser
 
Exploring Koltin on Android
Exploring Koltin on AndroidExploring Koltin on Android
Exploring Koltin on AndroidDeepanshu Madan
 
Kotlin: maybe it's the right time
Kotlin: maybe it's the right timeKotlin: maybe it's the right time
Kotlin: maybe it's the right timeDavide Cerbo
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScriptNone
 
Web app development_php_04
Web app development_php_04Web app development_php_04
Web app development_php_04Hassen Poreya
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript TutorialBui Kiet
 
Design Patterns the Ruby way - ConFoo 2015
Design Patterns the Ruby way - ConFoo 2015Design Patterns the Ruby way - ConFoo 2015
Design Patterns the Ruby way - ConFoo 2015Fred Heath
 
InterConnect: Server Side Swift for Java Developers
InterConnect:  Server Side Swift for Java DevelopersInterConnect:  Server Side Swift for Java Developers
InterConnect: Server Side Swift for Java DevelopersChris Bailey
 
unity-clinic2-unityscript-basics
unity-clinic2-unityscript-basicsunity-clinic2-unityscript-basics
unity-clinic2-unityscript-basicsDarren Woodiwiss
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An IntroductionManvendra Singh
 
Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Sven Efftinge
 
Polyglot Adventures for the Modern Java Developer #javaone2017
Polyglot Adventures for the Modern Java Developer #javaone2017Polyglot Adventures for the Modern Java Developer #javaone2017
Polyglot Adventures for the Modern Java Developer #javaone2017Mario-Leander Reimer
 

Semelhante a Swift-Programming Part 1 (20)

NUS iOS Swift Talk
NUS iOS Swift TalkNUS iOS Swift Talk
NUS iOS Swift Talk
 
Terraform at Scale
Terraform at ScaleTerraform at Scale
Terraform at Scale
 
An Introduction to Scala (2014)
An Introduction to Scala (2014)An Introduction to Scala (2014)
An Introduction to Scala (2014)
 
Intro toswift1
Intro toswift1Intro toswift1
Intro toswift1
 
Python basic
Python basicPython basic
Python basic
 
Why Scala is the better Java
Why Scala is the better JavaWhy Scala is the better Java
Why Scala is the better Java
 
Exploring Koltin on Android
Exploring Koltin on AndroidExploring Koltin on Android
Exploring Koltin on Android
 
Kotlin: maybe it's the right time
Kotlin: maybe it's the right timeKotlin: maybe it's the right time
Kotlin: maybe it's the right time
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
Web app development_php_04
Web app development_php_04Web app development_php_04
Web app development_php_04
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Design Patterns the Ruby way - ConFoo 2015
Design Patterns the Ruby way - ConFoo 2015Design Patterns the Ruby way - ConFoo 2015
Design Patterns the Ruby way - ConFoo 2015
 
InterConnect: Server Side Swift for Java Developers
InterConnect:  Server Side Swift for Java DevelopersInterConnect:  Server Side Swift for Java Developers
InterConnect: Server Side Swift for Java Developers
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
unity-clinic2-unityscript-basics
unity-clinic2-unityscript-basicsunity-clinic2-unityscript-basics
unity-clinic2-unityscript-basics
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]
 
Polyglot Adventures for the Modern Java Developer #javaone2017
Polyglot Adventures for the Modern Java Developer #javaone2017Polyglot Adventures for the Modern Java Developer #javaone2017
Polyglot Adventures for the Modern Java Developer #javaone2017
 

Mais de Mindfire Solutions (20)

Physician Search and Review
Physician Search and ReviewPhysician Search and Review
Physician Search and Review
 
diet management app
diet management appdiet management app
diet management app
 
Business Technology Solution
Business Technology SolutionBusiness Technology Solution
Business Technology Solution
 
Remote Health Monitoring
Remote Health MonitoringRemote Health Monitoring
Remote Health Monitoring
 
Influencer Marketing Solution
Influencer Marketing SolutionInfluencer Marketing Solution
Influencer Marketing Solution
 
ELMAH
ELMAHELMAH
ELMAH
 
High Availability of Azure Applications
High Availability of Azure ApplicationsHigh Availability of Azure Applications
High Availability of Azure Applications
 
IOT Hands On
IOT Hands OnIOT Hands On
IOT Hands On
 
Glimpse of Loops Vs Set
Glimpse of Loops Vs SetGlimpse of Loops Vs Set
Glimpse of Loops Vs Set
 
Oracle Sql Developer-Getting Started
Oracle Sql Developer-Getting StartedOracle Sql Developer-Getting Started
Oracle Sql Developer-Getting Started
 
Adaptive Layout In iOS 8
Adaptive Layout In iOS 8Adaptive Layout In iOS 8
Adaptive Layout In iOS 8
 
Introduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/MacIntroduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/Mac
 
LINQPad - utility Tool
LINQPad - utility ToolLINQPad - utility Tool
LINQPad - utility Tool
 
Get started with watch kit development
Get started with watch kit developmentGet started with watch kit development
Get started with watch kit development
 
Swift vs Objective-C
Swift vs Objective-CSwift vs Objective-C
Swift vs Objective-C
 
Material Design in Android
Material Design in AndroidMaterial Design in Android
Material Design in Android
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
 
Ext js Part 2- MVC
Ext js Part 2- MVCExt js Part 2- MVC
Ext js Part 2- MVC
 
ExtJs Basic Part-1
ExtJs Basic Part-1ExtJs Basic Part-1
ExtJs Basic Part-1
 
Spring Security Introduction
Spring Security IntroductionSpring Security Introduction
Spring Security Introduction
 

Último

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 

Último (20)

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 

Swift-Programming Part 1

  • 1. 1 Introduction of Swift Presenter: Waseem Ahmad, Mindfire Solutions Date: 28/10/2014
  • 2. What you will learn Presenter: Waseem Ahmad, Mindfire Solutions What is Swift? Variable Constants Type Inference Type Aliases String/Character Interpolation Array and Dictionary Loops Optionals, Unwrapping an Optional Functions Tuples Classes Properties Closures Q & A
  • 3. What is Swift ? • Swift is Apple’s modern, type-safe language for Cocoa development that builds on the best of C and Objective-C • Safe • Modern • Power Presenter: Waseem Ahmad, Mindfire Solutions
  • 4. Variables var variableName : String = “Swift” var version: Double = 1.0 var day: Int = 28 var isAnimated: Bool = true Presenter: Waseem Ahmad, Mindfire Solutions
  • 5. Constants &Variables let variableName: String = “Swift” var version: Double = 1.0 var day: Int = 28 var isAnimated: Bool = true Pretty clear which is constant and mutable, it’s define safe code in multithreaded environment. Make code more clear and readable. Presenter: Waseem Ahmad, Mindfire Solutions
  • 6. Constants &Variables let variableName: String = “Swift” var version: Double = 1.0 let day: Int = 28 let isAnimated: Bool = true Presenter: Waseem Ahmad, Mindfire Solutions
  • 7. Type Inference let variableName = “Swift” // As String var version = 1.0 // As Double/Float let day = 28 // As Int let isAnimated = true // As Boolean Code safe, these are valuable & constant explicitly type. Presenter: Waseem Ahmad, Mindfire Solutions
  • 8. Type Aliases An alternative name for an existing type. typealias AudioSample = UInt16 var maxAmplitudeFound = AudioSample.min Presenter: Waseem Ahmad, Mindfire Solutions
  • 9. Unicode Names let variableName = “Swift” // As String var version = 1.0 // As Double/Float let day = 28 // As Int let isAnimated = true // As Boolean let π = 3.1415927 let � = "emoji"� Presenter: Waseem Ahmad, Mindfire Solutions
  • 10. String var studentName: String = “Waseem” var studentName = “Waseem” // Inferred to be of type string Presenter: Waseem Ahmad, Mindfire Solutions
  • 11. String var studentName: String = “Waseem” var studentName = “Waseem” // Inferred to be of type string var documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String documentsPath = documentsPath.stringByAppendingString(subpath) Presenter: Waseem Ahmad, Mindfire Solutions
  • 12. Character let studentName = “Waseem" for character in studentName { println(character) } W a s e e m Presenter: Waseem Ahmad, Mindfire Solutions
  • 13. Complex String var name = “Waseem” var coins = 100 Congratulations, Waseem won 100 coins. Presenter: Waseem Ahmad, Mindfire Solutions
  • 14. String Interpolation var name = “Waseem” var coins = 100 Congratulations, Waseem won 100 coins. let message = “Congratulations, (name) won (coins)”. Presenter: Waseem Ahmad, Mindfire Solutions
  • 15. String Mutability var variableString = "Mindfire" Presenter: Waseem Ahmad, Mindfire Solutions
  • 16. String Mutability var variableString = “Mindfire" variableString += " Solutions” // variableString is now “Mindfire Solutions" Presenter: Waseem Ahmad, Mindfire Solutions
  • 17. String Mutability var variableString = “Mindfire" variableString += " Solutions” // variableString is now “Mindfire Solutions" let constantString = “Mindfire" constantString += " Solutions” // error - constantString cannot be changed Presenter: Waseem Ahmad, Mindfire Solutions
  • 18. String Mutability var variableString = “Mindfire" variableString += " Solutions” // variableString is now “Mindfire Solutions" let constantString = “Mindfire" constantString += " Solutions” // error - constantString cannot be changed Presenter: Waseem Ahmad, Mindfire Solutions
  • 19. Collection Type (Array & Dictionary) Presenter: Waseem Ahmad, Mindfire Solutions
  • 20. Array and Dictionary Literals var names = [“John”, “Bob”, "Brian", "Jack"] Presenter: Waseem Ahmad, Mindfire Solutions
  • 21. Array and Dictionary Literals var names = [“John”, “Bob”, "Brian", “Jack"] var numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4] Presenter: Waseem Ahmad, Mindfire Solutions
  • 22. Difference Between NSArray & NSDictionary - It could work with any type (String, Int etc) - Collection are typed collection Presenter: Waseem Ahmad, Mindfire Solutions
  • 23. Typed Collection var names = [“John”, “Bob”, "Brian", “Jack”, 123] var names = [“John”, “Bob”, "Brian", “Jack”, function()] Presenter: Waseem Ahmad, Mindfire Solutions
  • 24. Typed Collection var names: String[] = [“John”, “Bob”, "Brian", “Jack”] Presenter: Waseem Ahmad, Mindfire Solutions
  • 25. Typed Collection var names = [“John”, “Bob”, "Brian", “Jack”] // An array of String Values var numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4] // An Dictionary With String Keys and Int Values Typed collection made your code safe, you well know what you are retrieving and adding. Presenter: Waseem Ahmad, Mindfire Solutions
  • 26. Loop while !isTrue { print(“hello”) } for var i = 1; i <= 13; ++i { print(“hello”) } Presenter: Waseem Ahmad, Mindfire Solutions
  • 27. For-In: Strings and Characters let studentName = “Waseem" for character in studentName { println(character) } W a s e e m Swift Power, we can use character & emoji in similar way. Presenter: Waseem Ahmad, Mindfire Solutions
  • 28. For-In: Ranges for number in 1...5 { // Clause Range println("(number) times 4 is (number * 4)") } 1 times 4 is 4 2 times 4 is 8 3 times 4 is 12 4 times 4 is 16 5 times 4 is 20 Presenter: Waseem Ahmad, Mindfire Solutions
  • 29. For-In: Ranges for number in 0..5 { // half clause range println("(number) times 4 is (number * 4)") } 0 times 4 is 0 1 times 4 is 4 2 times 4 is 8 3 times 4 is 12 4 times 4 is 16 Presenter: Waseem Ahmad, Mindfire Solutions
  • 30. For-In: Array var names = [“John”, “Bob”, "Brian", "Jack"] for name in names { println("Hello (name)") } Presenter: Waseem Ahmad, Mindfire Solutions
  • 31. For-In: Dictionaries let numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4] ! for (animalName, legCount) in numberOfLegs { println("(animalName)s have (legCount) legs") } ants have 6 legs Power of swift extracting key and value in single loop, grouping of value is a power full feature of swift i.e Tuples Presenter: Waseem Ahmad, Mindfire Solutions
  • 32. Modification in Array var shoppingList = ["Eggs", "Milk"] println(shoppingList[0]) Presenter: Waseem Ahmad, Mindfire Solutions
  • 33. Modification in Array var shoppingList = ["Eggs", "Milk"] println(shoppingList[0]) shoppingList += "Flour" shoppingList += ["Cheese", "Butter", "Chocolate Spread"] Presenter: Waseem Ahmad, Mindfire Solutions
  • 34. Modification in Array var shoppingList = ["Eggs", "Milk"] shoppingList += "Flour" shoppingList += ["Cheese", "Butter", "Chocolate Spread”] shoppingList[0] = "Six eggs" Presenter: Waseem Ahmad, Mindfire Solutions
  • 35. Modification in Array var shoppingList = ["Eggs", "Milk"] shoppingList += "Flour" shoppingList += ["Cheese", "Butter", "Chocolate Spread”] shoppingList[0] = "Six eggs” ["Six eggs", "Milk", "Flour", "Cheese", "Butter", "Chocolate Spread"] shoppingList[3...5] = ["Bananas", “Apples"] ["Six eggs", "Milk", "Flour", "Bananas", “Apples"] Presenter: Waseem Ahmad, Mindfire Solutions
  • 36. Modification in Dictionary var numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4] numberOfLegs["spider"] = 273 Presenter: Waseem Ahmad, Mindfire Solutions
  • 37. Modification in Dictionary var numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4] numberOfLegs["spider"] = 273 numberOfLegs["spider"] = 8 What happen if we try to fetch a value that doesn’t have in array and dictionary? let lionLegCount = numberOfLegs[“lion”] // Nothing at all :) Presenter: Waseem Ahmad, Mindfire Solutions
  • 38. Optional var numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4] let lionLegCount: Int? = numberOfLegs["lion"] Presenter: Waseem Ahmad, Mindfire Solutions
  • 39. Optional var numberOfLegs = ["ant": 6, "snake": 0, "cheetah": 4] let lionLegCount: Int? = numberOfLegs[“lion"] if lionLegCount == nil { println("Lion wasn't found") } else { let legCount = lionLegCount! // unwrapping of optional value println("An lion has (legCount) legs") } Presenter: Waseem Ahmad, Mindfire Solutions
  • 40. Optional if numberOfLegs { let legCount = numberOfLegs! println("An Lion has (legCount) legs") } Presenter: Waseem Ahmad, Mindfire Solutions
  • 41. Unwrapping an Optional if let legCount = numberOfLegs { println("An Lion has (legCount) legs") } Note:- Braces are required with If :) Presenter: Waseem Ahmad, Mindfire Solutions
  • 42. Switch switch legCount { case 0: println("It slithers and slides around”) case 1: println("It hops") default: println("It walks") } Presenter: Waseem Ahmad, Mindfire Solutions
  • 43. Switch switch sender { case executeButton: println("You tapped the Execute button") case firstNameTextField: println("You tapped the First Name text field") default: println("You tapped some other object") } Presenter: Waseem Ahmad, Mindfire Solutions
  • 44. Switch switch legCount { case 0: println("It slithers and slides around")! case 1, 3, 5, 7, 9, 11, 13: println("It limps") case 2, 4, 6, 8, 10, 12, 14: println("It walks") } // error: switch must be exhaustive Presenter: Waseem Ahmad, Mindfire Solutions
  • 45. Switch switch legCount { case 0: println("It slithers and slides around")! case 1, 3, 5, 7, 9, 11, 13: println("It limps") case 2, 4, 6, 8, 10, 12, 14: println("It walks”) default: println("It walks") } Presenter: Waseem Ahmad, Mindfire Solutions
  • 46. Matching Value Ranges switch legCount { case 0: println("It slithers and slides around")! case 1…8: println("It has few lags") default: println("It walks") } Presenter: Waseem Ahmad, Mindfire Solutions
  • 48. Functions with Parameters func sayHello(name: String) { println("Hello (name)!") } Presenter: Waseem Ahmad, Mindfire Solutions
  • 49. Default Parameter Values func sayHello(name: String = "World") { println("Hello (name)!") } sayHello() // Hello World sayHello(“Team”) // Hello Team Presenter: Waseem Ahmad, Mindfire Solutions
  • 50. Returning Values func greetingMsg(name: String = "World") -> String { return "Hello " + name } let greeting = greetingMsg() Presenter: Waseem Ahmad, Mindfire Solutions
  • 51. Returning Multiple Values func getUsernInfo() -> (Int, String) { return (25, “John”) } Presenter: Waseem Ahmad, Mindfire Solutions
  • 52. Tuples -Grouping a values -Value could be any type (3.79, 3.99, 4.19) // (Double, Double, Double) (404, "Not found") (2, "banana", 0.72) -Tuple is not an replacement of structure but this is best when needs to return multiple values like from function func getUsernInfo() -> (Int, String) { return (25, “John”) } Presenter: Waseem Ahmad, Mindfire Solutions
  • 53. Decomposing of Tuples func getUsernInfo() -> (Int, String) { return (25, “John”) } let (age, name) = getUsernInfo() println(“This is (name) and my age is (age)") Presenter: Waseem Ahmad, Mindfire Solutions
  • 54. Decomposing of Tuples func getUsernInfo() -> (Int, String) { return (25, “John”) } let (age, name) = getUsernInfo() let (age: Int, name: String) = getUsernInfo() println(“This is (name) and my age is (age)") If you only need some of the tuple’s values, ignore parts of the tuple with an underscore (_) when you decompose the tuple: let (age, _) = getUsernInfo() Presenter: Waseem Ahmad, Mindfire Solutions
  • 55. Named Values in a Tuple func getUsernInfo() -> (age: Int, name: String) { return (25, “John”) } let userInfo = getUsernInfo() println(“This is (userInfo.name) and my age is (userInfo.age)”) Presenter: Waseem Ahmad, Mindfire Solutions
  • 56. Classes class Student { // properties // methods // initializers } class Student: NSObject { // no need to derive a class with base as NSObject } We can create a subclass and inherited class Medical: Student { } Presenter: Waseem Ahmad, Mindfire Solutions
  • 57. Properties class Student { var rollNo = 1 var name: String? // methods // initializers } The big difference between objective c and swift is “no difference between Instance variable and priorities”. Here rollNo we can say as stored properties. Presenter: Waseem Ahmad, Mindfire Solutions
  • 58. Computed Properties class Student { var rollNo = 1 var name: String? var description: String { get { return “Hi this (name!) and my roll number is (rollNo)“ } } } Presenter: Waseem Ahmad, Mindfire Solutions
  • 59. Computed Properties (RW) class Student { var rollNo = 1 var name: String? var description: String { get { return “Hi this (name!) and my roll number is (rollNo)“ } set { } } } Presenter: Waseem Ahmad, Mindfire Solutions
  • 60. Computed Properties (Read) class Student { var rollNo = 1 var name: String? var description: String { return “Hi this (name!) and my roll number is (rollNo)“ } } Presenter: Waseem Ahmad, Mindfire Solutions
  • 61. Initializer Class Syntax class Student { var rollNo = 1 var name: String? var description: String { return “Hi this (name!) and my roll number is (rollNo)“ } } let studentObj = Student() println(studentObj.description) - Automatic memory allocation -No need to write type as Swift support Type Inference let studentObj : Student = Student() Presenter: Waseem Ahmad, Mindfire Solutions
  • 62. Initializer Class Syntax class Student { var rollNo = 1 var name: String? init() { // constructor string = “Waseem” } var description: String { return “Hi this (name!) and my roll number is (rollNo)“ } } Presenter: Waseem Ahmad, Mindfire Solutions
  • 63. Overriding a Property class Medical: Student { init() { super.init() } override var description: String { // Safe return super.description + ", student of Medical" } } Presenter: Waseem Ahmad, Mindfire Solutions
  • 64. Property Observers class Loan: Bank { override var intrest: Double { willSet { // newValue is available here if intrest > 10.0 { // calculate // trigger } } } didSet { // oldValue is available here } } } Presenter: Waseem Ahmad, Mindfire Solutions
  • 65. Methods class Student { var rollNo = 1 var name: String? func studentName(nameStr: String) { name = nameStr } } Presenter: Waseem Ahmad, Mindfire Solutions
  • 66. Class Methods class func isFileExistAtPath(filePath: NSString) -> Bool { let filemanager = NSFileManager.defaultManager() return filemanager.fileExistsAtPath(filePath) } Presenter: Waseem Ahmad, Mindfire Solutions
  • 67. Class De-initialisation class Student { var rollNo = 1 var name: String? init() { // constructor fileOpen() // } deinit { // constructor closeFile() // } } Presenter: Waseem Ahmad, Mindfire Solutions
  • 68. iPhone App to Advertise Real Estate Case Study www.mindfiresolutions.com
  • 69. Next Seminar: Swift in depth Closures Structures Enum Extensions Memory Management Optional Chaining Generic type Presenter: Waseem Ahmad, Mindfire Solutions
  • 70. References - Apple WWDC 2014 - Apple Inc. “The Swift Programming Language.” iBooks. Presenter: Waseem Ahmad, Mindfire Solutions
  • 71. Presenter: Waseem Ahmad, Mindfire Solutions Question and Answer
  • 72. Thank you Presenter: Waseem Ahmad, Mindfire Solutions