Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift Intro

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)

Florian

July 08, 2014
Tweet

More Decks by Florian

Other Decks in Technology

Transcript

  1. let first = "First " let nine = 9 let

    patch = first + nine 'String' is not convertible to 'UInt8'
  2. let first = "First " let nine = 9 let

    patch = first + String(nine) "First 9"
  3. var optionalName: String? = "John Appleseed" ! var greeting =

    "Hello!" if let name = optionalName { greeting = "Hello, \ (name)" }
  4. var optionalName: String? = "John Appleseed" ! var greeting =

    "Hello!" if let name = optionalName { greeting = "Hello, \ (name)" }
  5. var optionalName: String? = "John Appleseed" ! var greeting =

    "Hello!" if let name = optionalName { greeting = "Hello, \ (name)" }
  6. class Server: NSObject, Equatable, NSCoding { var gooRequests = 0

    var badRequests = 0 var alias: NSString var url: NSURL (...) }
  7. func == (lhs: Server, rhs: Server) -> Bool { return

    lhs.alias == rhs.alias && lhs.url == rhs.url }
  8. func == (lhs: Server, rhs: Server) -> Bool { return

    lhs.alias == rhs.alias && lhs.url == rhs.url }
  9. func == (lhs: Server, rhs: Server) -> Bool { return

    lhs.alias == rhs.alias && lhs.url == rhs.url }
  10. protocol Comparable : Equatable { func <=(lhs: Self, rhs: Self)

    -> Bool func >=(lhs: Self, rhs: Self) -> Bool func >(lhs: Self, rhs: Self) -> Bool }
  11. protocol Comparable : Equatable { func <=(lhs: Self, rhs: Self)

    -> Bool func >=(lhs: Self, rhs: Self) -> Bool func >(lhs: Self, rhs: Self) -> Bool }
  12. let _SingletonASharedInstance = SingletonA() ! class SingletonA { ! class

    var sharedInstance : SingletonA { return _SingletonASharedInstance } ! }
  13. class Manager { class var sharedInstance :Manager { ! struct

    Static { static let instance :Manager = ServerManager() } return Static.instance } } https://github.com/hpique/SwiftSingleton
  14. let _SingletonASharedInstance = SingletonA() ! class Manager { ! class

    var sharedInstance :Manager { return _SingletonASharedInstance } ! } Private Konstanten (hoffentlich) in nächster Version
  15. class Controller { var title: String = "aTitle" { !

    willSet(newTitle) { println("About to set title to \(newTitle)") } ! } }
  16. ! let controller = Controller() controller.title = "Hello" ! //

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