O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.
Swift Programming
Language
Hello World
println(“Hello World!”)
//var using make a variable.
var hello = “Hello”
//let using make a constants.
let wor...
Simple Values
var name = “ANIL”
//Weight type is Double.
var weight: Double = 74.4
//Correct.
var myVariable = 4
myVariabl...
Simple Values
var text = “ANIL”
var number = 7
//Combining two variables to one variable.
var textNumber = text + String(n...
For - If - Else - Else If
//0,1,2,3,4,5,6,7,8,9
for var i = 0; i < 10; i++ {
println(i)
}
//1,2,3,4,5
for i in 1…5 {
print...
Switch - Case
var str = “Swift”
//break is automatically in Swift
switch str {
case “Swift”, “swift”:
println(“Swift”)
cas...
Switch - Case
let somePoint = (2,0)
//We can giving a label.
mainSwitch: switch somePoint {
case (2,0) where somePoint.0 =...
Array - Dictionary
//Make an array.
var cities = [“Istanbul”, “Sivas”, “San Francisco”, “Seul”]
println(cities[0])
//Make ...
Array
var stringArray = [“Hello”, “World”]
//Add element into the array.
stringArray.append(“Objective - C”)
//Insert elem...
//Get element into the array.
stringArray[1]
stringArray[1…3]
//Get all elements into the array.
for (index, value) in enu...
var airports = [“SAW” : “Sabiha Gokcen Havalimani”,
“IST” : “Ataturk Havalimani”]
//Add element in the dictionary.
airport...
Dictionary
//Remove element in the dictionary.
airports.removeValueForKey(“JFK”)
//Get all elements into the dictionary.
f...
Functions
//Make a function.
func hello(){
println(“Hello World!”)
}
//Call a function.
hello()
//personName is parameter ...
Functions
/*#it works, same parameter name and parameter tag
name. This function returned String value. */
func printName(...
Functions
//Tuple returns multiple value.
func sumAndCeiling(#numberOne: Int numberTwo: Int)
-> (sum: Int, ceiling: Int){
...
Functions
func double(number:Int) -> Int {
return number * 2
}
func triple(number:Int) -> Int {
return number * 3
}
func m...
Functions
/* This function have inner function and returned
function, buildIncrementor function returned function
and incr...
Functions
/* Take unlimited parameter functions */
func avarage(#numbers:Int…) -> Int {
var total = 0;
for n in numbers{
t...
Structs
/* Creating Struct */
struct GeoPoint {
//Swift doesn’t like empty values
var latitude = 0.0
var longitude = 0.0
}...
Classes
/* Creating Class */
class Person {
var name:String
var age:Int
//nickname:String? is optional value.
var nickname...
Classes
/* Creating Sub Class */
class Class : SuperClass {
var name:String
init(name:String){
self.name = name
super.init...
Classes
/* Creating Class (Static) Method */
class MyClass {
class func printWord(#word:String) {
println(word)
}
}
/* Cal...
Enums
/* Creating Enum */
enum Direction {
case Left
case Right
case Up
case Down
}
//Call Enum Value
Direction.Right
or
v...
Enums
/* Creating Enum with Parameter(s) */
enum Computer {
//RAM, Processor
case Desktop(Int,String)
//Screen Size
case L...
Enums
/* Creating Enum with Int */
enum Planet:Int {
case Mercury = 1, Venus, Earth, Mars, Jupiter, Saturn,
Uranus, Neptun...
Próximos SlideShares
Carregando em…5
×

de

Swift Programming Language Slide 1 Swift Programming Language Slide 2 Swift Programming Language Slide 3 Swift Programming Language Slide 4 Swift Programming Language Slide 5 Swift Programming Language Slide 6 Swift Programming Language Slide 7 Swift Programming Language Slide 8 Swift Programming Language Slide 9 Swift Programming Language Slide 10 Swift Programming Language Slide 11 Swift Programming Language Slide 12 Swift Programming Language Slide 13 Swift Programming Language Slide 14 Swift Programming Language Slide 15 Swift Programming Language Slide 16 Swift Programming Language Slide 17 Swift Programming Language Slide 18 Swift Programming Language Slide 19 Swift Programming Language Slide 20 Swift Programming Language Slide 21 Swift Programming Language Slide 22 Swift Programming Language Slide 23 Swift Programming Language Slide 24 Swift Programming Language Slide 25
Próximos SlideShares
Introduction to Swift programming language.
Avançar

3 gostaram

Compartilhar

Swift Programming Language

Swift Programming Language

Swift Programming Language

  1. 1. Swift Programming Language
  2. 2. Hello World println(“Hello World!”) //var using make a variable. var hello = “Hello” //let using make a constants. let world = “World!” println(“(hello) (world)”)
  3. 3. Simple Values var name = “ANIL” //Weight type is Double. var weight: Double = 74.4 //Correct. var myVariable = 4 myVariable = 10 //Wrong, because myVariable type is Integer now. var myVariable = 4 myVariable = “Four”
  4. 4. Simple Values var text = “ANIL” var number = 7 //Combining two variables to one variable. var textNumber = text + String(number) println(textNumber)
  5. 5. For - If - Else - Else If //0,1,2,3,4,5,6,7,8,9 for var i = 0; i < 10; i++ { println(i) } //1,2,3,4,5 for i in 1…5 { println(i) } if condition { /* Codes */ } else if condition { /* Codes */ } else { /* Codes */ }
  6. 6. Switch - Case var str = “Swift” //break is automatically in Swift switch str { case “Swift”, “swift”: println(“Swift”) case “Objective - C”: println(“Objective - C”) default: println(“Other Language”) }
  7. 7. Switch - Case let somePoint = (2,0) //We can giving a label. mainSwitch: switch somePoint { case (2,0) where somePoint.0 == 2: println(“2,0”) //Second case working to. fallthrough //x value doesn’t matter. case (_,0): println(“_,0”) default: println(“Other Point”) }
  8. 8. Array - Dictionary //Make an array. var cities = [“Istanbul”, “Sivas”, “San Francisco”, “Seul”] println(cities[0]) //Make a dictionary. var cityCodes = [ “Istanbul Anadolu” : “216”, “Istanbul Avrupa” : “212”, “Ankara” : ”312” ] println(cityCodes[“Istanbul Anadolu”]!)
  9. 9. Array var stringArray = [“Hello”, “World”] //Add element into the array. stringArray.append(“Objective - C”) //Insert element into the array. stringArray.insert(“Apple”, atIndex: 2) //Remove element into the array. stringArray.removeAtIndex(3) //Remove last element into the array. stringArray.removeLast()
  10. 10. //Get element into the array. stringArray[1] stringArray[1…3] //Get all elements into the array. for (index, value) in enumerate(stringArray) { println(“(index + 1). value is: (value)”) } //Get element count in the array. stringArray.count Array
  11. 11. var airports = [“SAW” : “Sabiha Gokcen Havalimani”, “IST” : “Ataturk Havalimani”] //Add element in the dictionary. airports[“JFK”] = “John F Kennedy” //Get element count in the dictionary. airports.count //Update element in the dictionary. airports.updateValue(“John F Kennedy Terminal”, forKey: “JFK”) Dictionary
  12. 12. Dictionary //Remove element in the dictionary. airports.removeValueForKey(“JFK”) //Get all elements into the dictionary. for (airportCode, airport) in airports { println(“Airport Code: (airportCode) Airport: (airport)”) } //Get all keys. var keysArray = airports.keys //Get all values. var valuesArray = airports.values
  13. 13. Functions //Make a function. func hello(){ println(“Hello World!”) } //Call a function. hello() //personName is parameter tag name. func helloTo(personName name:String){ println(“Hello (name)”) }
  14. 14. Functions /*#it works, same parameter name and parameter tag name. This function returned String value. */ func printName(#name: String) -> String{ return name } //This function returned Int value. func sum(#numberOne: Int numberTwo: Int) -> Int{ return numberOne + numberTwo }
  15. 15. Functions //Tuple returns multiple value. func sumAndCeiling(#numberOne: Int numberTwo: Int) -> (sum: Int, ceiling: Int){ var ceiling = numberOne > numberTwo ? numberOne : numberTwo var sum = numberOne + numberTwo return (sum,ceiling) }
  16. 16. Functions func double(number:Int) -> Int { return number * 2 } func triple(number:Int) -> Int { return number * 3 } func modifyInt(#number:Int modifier:Int -> Int) -> Int { return modifier(number) } //Call functions modifyInt(number: 4 modifier: double) modifyInt(number: 4 modifier: triple)
  17. 17. Functions /* This function have inner function and returned function, buildIncrementor function returned function and incrementor function returned Int value. */ func buildIncrementor() -> () -> Int { var count = 0 func incrementor() -> Int{ count++ return count } return incrementor }
  18. 18. Functions /* Take unlimited parameter functions */ func avarage(#numbers:Int…) -> Int { var total = 0; for n in numbers{ total += n; } return total / numbers.count; }
  19. 19. Structs /* Creating Struct */ struct GeoPoint { //Swift doesn’t like empty values var latitude = 0.0 var longitude = 0.0 } /* Initialize Struct */ var geoPoint = GeoPoint() geoPoint.latitude = 44.444 geoPoint.longitude = 12.222
  20. 20. Classes /* Creating Class */ class Person { var name:String var age:Int //nickname:String? is optional value. var nickname:String? init(name:String, age:Int, nickname:String? = nil){ self.name = name self.age = age self.nickname = nickname } }
  21. 21. Classes /* Creating Sub Class */ class Class : SuperClass { var name:String init(name:String){ self.name = name super.init(age: age, nickname: nickname) } func printName(){ println(name) } }
  22. 22. Classes /* Creating Class (Static) Method */ class MyClass { class func printWord(#word:String) { println(word) } } /* Calling Class (Static) Method */ MyClass.printWord(word: “Hello World!”)
  23. 23. Enums /* Creating Enum */ enum Direction { case Left case Right case Up case Down } //Call Enum Value Direction.Right or var direction:Direction direction = .Up
  24. 24. Enums /* Creating Enum with Parameter(s) */ enum Computer { //RAM, Processor case Desktop(Int,String) //Screen Size case Laptop(Int) } //Call Enum Value with Parameter(s) var computer = Computer.Desktop(16,”i7”)
  25. 25. Enums /* Creating Enum with Int */ enum Planet:Int { case Mercury = 1, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune } /* Call Enum Value for Raw Value */ //Returns 3 Planet.Earth.toRaw() //Returns Mars (Optional Value) Planet.Earth.fromRaw(4)
  • ali1ali2

    Nov. 29, 2017
  • dragon515

    Jan. 13, 2015
  • ibrhmozdgn

    Dec. 16, 2014

Swift Programming Language

Vistos

Vistos totais

2.320

No Slideshare

0

De incorporações

0

Número de incorporações

179

Ações

Baixados

1

Compartilhados

0

Comentários

0

Curtir

3

×