Skip to content

Instantly share code, notes, and snippets.

@NeedMoreDesu
Created November 12, 2017 19:11
Show Gist options
  • Save NeedMoreDesu/64bbdb1dcb70463f4a2cdf61c494f3db to your computer and use it in GitHub Desktop.
Save NeedMoreDesu/64bbdb1dcb70463f4a2cdf61c494f3db to your computer and use it in GitHub Desktop.
//Example of turning structs into Createable & Updateable
struct SomeStruct: CreateableDefault {
var someInt = 12
var someString = "asdf"
}
let a = SomeStruct.create {
$0.someInt = 10
$0.someString = "abcd"
}!
a.update {
$0.someInt = 42
$0.someString = "efg"
}
//Example of defining how to create UIViewController out from storyboard:
class SomeVC: UIViewController, Createable {
var someInputParam: SomeStruct!
static func create() -> Any? {
let storyboard = UIStoryboard(name: "SomeStoryboard", bundle: Bundle.main)
return storyboard.instantiateViewController(withIdentifier: "SomeVC")
}
}
SomeVC.create {
$0.someInputParam = SomeStruct.create {
$0.someInt = 9000
$0.someString = "You get the idea"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment