Created
November 12, 2017 19:11
-
-
Save NeedMoreDesu/64bbdb1dcb70463f4a2cdf61c494f3db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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