Created
January 7, 2020 01:01
-
-
Save aainaj/1544b9047a94b0e0015803808d58f3fc to your computer and use it in GitHub Desktop.
This file contains 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
import Foundation | |
import UIKit | |
class ListViewController: UIViewController { | |
var listTitle: (() -> String)? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
listTitle = { | |
print("closure executed") | |
return "Fiction Books" | |
} | |
} | |
} | |
class DetailViewController: UIViewController { | |
var listTitle: (() -> String)? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
guard let title = listTitle?() else { return } | |
self.title = title | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment