Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Create a new project...
- - Embed the default View Controller in a Navigation Controller
- - add two buttons: "Push" and "Present"
- Connect the buttons to these actions:
- */
- class ViewController: UIViewController {
- @IBAction func doPush(_ sender: Any) {
- if let vc = storyboard?.instantiateViewController(withIdentifier: "ProfileViewController") {
- navigationController?.pushViewController(vc, animated: true)
- }
- }
- @IBAction func doPresent(_ sender: Any) {
- if let vc = storyboard?.instantiateViewController(withIdentifier: "ProfileViewController") {
- present(vc, animated: true, completion: nil)
- }
- }
- }
- /*
- - add another View Controller (ProfileViewController)
- - add one button: "Done"
- Connect the button to this action:
- */
- class ProfileViewController: UIViewController {
- @IBAction func gotTap(_ sender: Any) {
- if let pvc = presentingViewController {
- pvc.dismiss(animated: true, completion: nil)
- } else {
- navigationController?.popViewController(animated: true)
- }
- }
- deinit {
- print("ProfileViewController deinit")
- }
- }
- /*
- Run the app...
- See if you get "ProfileViewController deinit" as expected.
- Check the Memory Graph to see if it looks the same as your app.
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement