let _SingletonASharedInstance =
SingletonA()
!
class SingletonA {
!
class var sharedInstance : SingletonA {
return _SingletonASharedInstance
}
!
}
Slide 55
Slide 55 text
Konstante
public
Slide 56
Slide 56 text
class Manager {
class var sharedInstance :Manager {
!
struct Static {
static let instance
:Manager = ServerManager()
}
return Static.instance
}
}
https://github.com/hpique/SwiftSingleton
Slide 57
Slide 57 text
structs support
static
constants
Slide 58
Slide 58 text
let _SingletonASharedInstance =
SingletonA()
!
class Manager {
!
class var sharedInstance :Manager {
return _SingletonASharedInstance
}
!
} Private Konstanten (hoffentlich) in
nächster Version
Slide 59
Slide 59 text
Properties
Slide 60
Slide 60 text
class Controller {
var title: String = "aTitle" {
!
willSet(newTitle) {
println("About to set
title to \(newTitle)")
}
!
}
}
Slide 61
Slide 61 text
class Controller {
(...)
didSet {
println("Changed
title \(oldValue) to \(title)")
}
(...)
Slide 62
Slide 62 text
!
let controller = Controller()
controller.title = "Hello"
!
// Console output
About to set title to Hello
Changed title aTitle to Hello
Slide 63
Slide 63 text
“The Swift Programming
Language”
!
https://itunes.apple.com/de/book/swift-
programming-language/id881256329?
l=en&mt=11
Slide 64
Slide 64 text
“Using Swift with Cocoa
and Objective-C”
!
https://itunes.apple.com/de/book/using-
swift-cocoa-objective/id888894773?l=en&mt=11
Slide 65
Slide 65 text
Follow the Swift
engineers
(e.g. Chris Lattner)
!
https://twitter.com/olebegemann/status/
482274302805700608