Swift Intro

896e816a54b484b5233ed5f9ea5278a5?s=47 Florian
July 08, 2014

Swift Intro

A short introduction and tidbits for the new programming language from Apple called Swift. I talked about this at our monthly mobile development user group meet up in Stuttgart (http://mobilemaultaschen.de)

896e816a54b484b5233ed5f9ea5278a5?s=128

Florian

July 08, 2014
Tweet

Transcript

  1. 1.
  2. 11.
  3. 12.

    let first = "First " let nine = 9 let

    patch = first + nine 'String' is not convertible to 'UInt8'
  4. 13.

    let first = "First " let nine = 9 let

    patch = first + String(nine) "First 9"
  5. 17.
  6. 21.

    var optionalName: String? = "John Appleseed" ! var greeting =

    "Hello!" if let name = optionalName { greeting = "Hello, \ (name)" }
  7. 22.

    var optionalName: String? = "John Appleseed" ! var greeting =

    "Hello!" if let name = optionalName { greeting = "Hello, \ (name)" }
  8. 23.

    var optionalName: String? = "John Appleseed" ! var greeting =

    "Hello!" if let name = optionalName { greeting = "Hello, \ (name)" }
  9. 34.

    class Server: NSObject, Equatable, NSCoding { var gooRequests = 0

    var badRequests = 0 var alias: NSString var url: NSURL (...) }
  10. 36.

    func == (lhs: Server, rhs: Server) -> Bool { return

    lhs.alias == rhs.alias && lhs.url == rhs.url }
  11. 37.

    func == (lhs: Server, rhs: Server) -> Bool { return

    lhs.alias == rhs.alias && lhs.url == rhs.url }
  12. 38.

    func == (lhs: Server, rhs: Server) -> Bool { return

    lhs.alias == rhs.alias && lhs.url == rhs.url }
  13. 41.

    protocol Comparable : Equatable { func <=(lhs: Self, rhs: Self)

    -> Bool func >=(lhs: Self, rhs: Self) -> Bool func >(lhs: Self, rhs: Self) -> Bool }
  14. 42.

    protocol Comparable : Equatable { func <=(lhs: Self, rhs: Self)

    -> Bool func >=(lhs: Self, rhs: Self) -> Bool func >(lhs: Self, rhs: Self) -> Bool }
  15. 43.
  16. 53.
  17. 54.

    let _SingletonASharedInstance = SingletonA() ! class SingletonA { ! class

    var sharedInstance : SingletonA { return _SingletonASharedInstance } ! }
  18. 56.

    class Manager { class var sharedInstance :Manager { ! struct

    Static { static let instance :Manager = ServerManager() } return Static.instance } } https://github.com/hpique/SwiftSingleton
  19. 58.

    let _SingletonASharedInstance = SingletonA() ! class Manager { ! class

    var sharedInstance :Manager { return _SingletonASharedInstance } ! } Private Konstanten (hoffentlich) in nächster Version
  20. 60.

    class Controller { var title: String = "aTitle" { !

    willSet(newTitle) { println("About to set title to \(newTitle)") } ! } }
  21. 62.

    ! let controller = Controller() controller.title = "Hello" ! //

    Console output About to set title to Hello Changed title aTitle to Hello