Skip to content

Instantly share code, notes, and snippets.

@aainaj
Created January 7, 2020 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aainaj/1544b9047a94b0e0015803808d58f3fc to your computer and use it in GitHub Desktop.
Save aainaj/1544b9047a94b0e0015803808d58f3fc to your computer and use it in GitHub Desktop.
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