Skip to content

Instantly share code, notes, and snippets.

@martin-cotta
Created October 26, 2015 18:56
Show Gist options
  • Save martin-cotta/8bfd8e525b15251a21ab to your computer and use it in GitHub Desktop.
Save martin-cotta/8bfd8e525b15251a21ab to your computer and use it in GitHub Desktop.
class AppContext {
let device : UIDevice
// Delay object creation
lazy var dataService: DataService = DataService()
// Property is depended on other parts of a class, that aren’t available yet
lazy var isTablet: Bool = { [unowned self] in
self.device.userInterfaceIdiom == .Pad
}()
init (device: UIDevice) {
self.device = device
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment