How to use viewWillAppear method of ViewController class

Best Swift-snapshot-testing code snippet using ViewController.viewWillAppear

SearchViewControllerSpec.swift

Source:SearchViewControllerSpec.swift Github

copy

Full Screen

...54        describe("when view appeared") {55            var titleView: SearchTitleView!56            57            beforeEach {58                viewController.viewWillAppear(false)59                60                titleView = viewController.navigationController!.navigationBar.subviews.last! as? SearchTitleView61            }62            63            it("needs to setup title view's delegate") {64                expect(titleView.delegate) === viewController65            }66            67            it("needs to setup title view's frame") {68                expect(titleView.frame.origin) == CGPoint(x: 8, y: 0)69                expect(titleView.frame.size) == CGSize(width: viewController.view.frame.size.width - 8 * 2, height: 44)70            }71            72            it("needs to setup title view's alpha") {73                expect(titleView.alpha) == 174            }75            76            it("needs to setup correct title bar tint color") {77                expect(viewController.navigationController?.navigationBar.barTintColor) == Colors.backgroundDefault78            }79        }80            81        describe("when view disappeared") {82            beforeEach {83                viewController.viewWillAppear(false)84                viewController.viewWillDisappear(false)85            }86            87            it("needs to setup correct title bar tint color") {88                expect(viewController.navigationController?.navigationBar.barTintColor) == UIColor.white89            }90        }91        92        describe("when title view's text changed") {93            it("needs to setup search phrase of view model") {94                viewController.viewWillAppear(false)95                96                let titleView = viewController.navigationController!.navigationBar.subviews.last! as! SearchTitleView97                titleView.textField.text = "phrase"98                titleView.textField.sendActions(for: .editingChanged)99                100                expect(viewModelMock.searchPhrase.value) == titleView.text101            }102        }103        104        describe("when data loaded") {105            context("if data is empty") {106                it("should have collection view without data") {107                    viewModelMock.isNeedToReturnData = false108                    viewModelMock.reloadData()109                    110                    expect(viewController.refreshControl?.isRefreshing) == false111                    expect(viewController.collectionView.numberOfItems(inSection: 0)) == 0112                    expect(viewController.collectionProvider.products.isEmpty) == true113                }114            }115            116            context("if data isn't empty") {117                it("should have collection view with data") {118                    viewModelMock.isNeedToReturnData = true119                    viewModelMock.reloadData()120                    121                    expect(viewController.refreshControl?.isRefreshing) == false122                    expect(viewController.collectionView.numberOfItems(inSection: 0)) > 0123                    expect(viewController.collectionProvider.products.isEmpty) == false124                }125            }126        }127        128        describe("when data refreshed or loaded next page") {129            it("should refresh data") {130                viewController.pullToRefreshHandler()131                132                expect(viewModelMock.isReloadDataStarted) == true133            }134            135            it("should load next page") {136                viewController.infinityScrollHandler()137                138                expect(viewModelMock.isLoadNextPageStarted) == true139            }140        }141        142        describe("when collection view item selected") {143            var titleView: SearchTitleView!144            145            beforeEach {146                viewController.viewWillAppear(false)147                148                viewModelMock.isNeedToReturnData = true149                viewModelMock.reloadData()150                151                titleView = viewController.navigationController!.navigationBar.subviews.last! as? SearchTitleView152                titleView.textField.sendActions(for: .editingDidBegin)153                154                let indexPath = IndexPath(item: 0, section: 0)155                viewController.collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .top)156                viewController.collectionView.delegate!.collectionView!(viewController.collectionView, didSelectItemAt: indexPath)157            }158            159            it("needs to end editing view") {160                expect(titleView.textField.isEditing) == false161            }162            163            it("needs to setup title view's alpha") {164                expect(titleView.alpha) == 0165            }166            167            it("needs to setup title view's alpha when user returns back") {168                viewController.viewWillAppear(false)169                170                expect(titleView.alpha) == 1171            }172        }173        174        describe("when category selected") {175            it("needs to setup title view's alpha") {176                viewController.viewWillAppear(false)177                178                let categoryListViewController = viewController.children.first! as! CategoryListViewController179                categoryListViewController.collectionProvider = CategoryListCollectionProvider()180                categoryListViewController.collectionProvider.delegate = categoryListViewController181                categoryListViewController.collectionView.dataSource = categoryListViewController.collectionProvider182                categoryListViewController.collectionView.delegate = categoryListViewController.collectionProvider183                184                let repositoryMock = CategoryRepositoryMock()185                let categoryListUseCaseMock = CategoryListUseCaseMock(repository: repositoryMock)186                let viewModelMock = CategoryListViewModelMock(categoryListUseCase: categoryListUseCaseMock)187                categoryListViewController.viewModel = viewModelMock188                viewModelMock.isNeedToReturnData = true189                viewModelMock.reloadData()190                191                categoryListViewController.collectionProvider.categories = viewModelMock.items.value192                categoryListViewController.collectionView.reloadData()193                194                let indexPath = IndexPath(item: 0, section: 0)195                categoryListViewController.collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .top)196                categoryListViewController.collectionView.delegate!.collectionView!(viewController.collectionView, didSelectItemAt: indexPath)197                198                let titleView = viewController.navigationController!.navigationBar.subviews.last! as! SearchTitleView199                200                expect(titleView.alpha) == 0201            }202        }203        204        describe("when title view editing begined") {205            it("needs to hide category list") {206                viewController.viewWillAppear(false)207                208                let titleView = viewController.navigationController!.navigationBar.subviews.last! as! SearchTitleView209                titleView.textField.sendActions(for: .editingDidBegin)210                211                expect(categoryListContainerView.alpha) == 0212            }213        }214        215        describe("when title view editing changed") {216            it("needs to reload search items") {217                viewController.viewWillAppear(false)218                219                let titleView = viewController.navigationController!.navigationBar.subviews.last! as! SearchTitleView220                titleView.textField.sendActions(for: .editingDidBegin)221                222                waitUntil(timeout: 2) { done in223                    DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1), execute: {224                        done()225                    })226                }227                228                titleView.textField.text = "phrase"229                titleView.textField.sendActions(for: .editingChanged)230                231                expect(viewModelMock.isReloadDataStarted).toEventually(equal(true), timeout: 1, pollInterval: 0.3)232            }233        }234        235        describe("when title view's clear button pressed") {236            it("needs to clear search result") {237                viewController.viewWillAppear(false)238                239                let titleView = viewController.navigationController!.navigationBar.subviews.last! as! SearchTitleView240                let clearButton = self.findView(withAccessibilityLabel: "clear", in: titleView) as! UIButton241                clearButton.sendActions(for: .touchUpInside)242                243                expect(viewModelMock.isResultCleared) == true244            }245        }246        247        describe("when title view's back button pressed") {248            it("needs to clear search result and show category list") {249                viewController.viewWillAppear(false)250                251                let titleView = viewController.navigationController!.navigationBar.subviews.last! as! SearchTitleView252                let backButton = self.findView(withAccessibilityLabel: "back", in: titleView) as! UIButton253                backButton.sendActions(for: .touchUpInside)254                255                expect(viewModelMock.isResultCleared) == true256                expect(categoryListContainerView.alpha) == 1257            }258        }259    }260}...

Full Screen

Full Screen

UIViewController+AddBehaviors.swift

Source: UIViewController+AddBehaviors.swift Github

copy

Full Screen

...10// and scrollView content inset changes based on keyboard frame.11import UIKit12protocol ViewControllerLifecycleBehavior {13    func viewDidLoad(viewController: UIViewController)14    func viewWillAppear(viewController: UIViewController)15    func viewDidAppear(viewController: UIViewController)16    func viewWillDisappear(viewController: UIViewController)17    func viewDidDisappear(viewController: UIViewController)18    func viewWillLayoutSubviews(viewController: UIViewController)19    func viewDidLayoutSubviews(viewController: UIViewController)20}21// Default implementations22extension ViewControllerLifecycleBehavior {23    func viewDidLoad(viewController _: UIViewController) {}24    func viewWillAppear(viewController _: UIViewController) {}25    func viewDidAppear(viewController _: UIViewController) {}26    func viewWillDisappear(viewController _: UIViewController) {}27    func viewDidDisappear(viewController _: UIViewController) {}28    func viewWillLayoutSubviews(viewController _: UIViewController) {}29    func viewDidLayoutSubviews(viewController _: UIViewController) {}30}31extension UIViewController {32    /*33     Add behaviors to be hooked into this view controller’s lifecycle.34     This method requires the view controller’s view to be loaded, so it’s best to call35     in `viewDidLoad` to avoid it being loaded prematurely.36     - parameter behaviors: Behaviors to be added.37     */38    func addBehaviors(_ behaviors: [ViewControllerLifecycleBehavior]) {39        let behaviorViewController = LifecycleBehaviorViewController(behaviors: behaviors)40        addChild(behaviorViewController)41        view.addSubview(behaviorViewController.view)42        behaviorViewController.didMove(toParent: self)43    }44    private final class LifecycleBehaviorViewController: UIViewController, UIGestureRecognizerDelegate {45        private let behaviors: [ViewControllerLifecycleBehavior]46        // MARK: - Lifecycle47        init(behaviors: [ViewControllerLifecycleBehavior]) {48            self.behaviors = behaviors49            super.init(nibName: nil, bundle: nil)50        }51        @available(*, unavailable)52        required init?(coder _: NSCoder) {53            fatalError("init(coder:) has not been implemented")54        }55        override func viewDidLoad() {56            super.viewDidLoad()57            view.isHidden = true58            applyBehaviors { behavior, viewController in59                behavior.viewDidLoad(viewController: viewController)60            }61        }62        override func viewWillAppear(_ animated: Bool) {63            super.viewWillAppear(animated)64            applyBehaviors { behavior, viewController in65                behavior.viewWillAppear(viewController: viewController)66            }67        }68        override func viewDidAppear(_ animated: Bool) {69            super.viewDidAppear(animated)70            applyBehaviors { behavior, viewController in71                behavior.viewDidAppear(viewController: viewController)72            }73        }74        override func viewWillDisappear(_ animated: Bool) {75            super.viewWillDisappear(animated)76            applyBehaviors { behavior, viewController in77                behavior.viewWillDisappear(viewController: viewController)78            }79        }...

Full Screen

Full Screen

PresenterInterface.swift

Source:PresenterInterface.swift Github

copy

Full Screen

...6//  Copyright © 2021 Iflet.tech. All rights reserved.7//8protocol PresenterInterface: class {9    func viewDidLoad()10    func viewWillAppear(animated: Bool)11    func viewDidAppear(animated: Bool)12    func viewWillDisappear(animated: Bool)13    func viewDidDisappear(animated: Bool)14}15// MARK: - Presenter Interface Helpers16/// PresenterInterface extra capabilities (for checking wether it's properly called on ViewController)17extension PresenterInterface {18    /// Throw an error if presenter called viewDidLoad but hasn't been called inside ViewController19    func viewDidLoad() {20        fatalError("viewDidLoad hasn't been called inside ViewController")21    }22    /// Throw an error if presenter called viewWillAppear but hasn't been called inside ViewController23    func viewWillAppear(animated: Bool) {24        fatalError("viewWillAppear hasn't been called inside ViewController")25    }26    /// Throw an error if presenter called viewDidAppear but hasn't been called inside ViewController27    func viewDidAppear(animated: Bool) {28        fatalError("viewDidAppear hasn't been called inside ViewController")29    }30    /// Throw an error if presenter called viewWillDisappear but hasn't been called inside ViewController31    func viewWillDisappear(animated: Bool) {32        fatalError("viewWillDisappear hasn't been called inside ViewController")33    }34    /// Throw an error if presenter called viewDidDisappear but hasn't been called inside ViewController35    func viewDidDisappear(animated: Bool) {36        fatalError("viewDidDisappear hasn't been called inside ViewController")37    }38}...

Full Screen

Full Screen

viewWillAppear

Using AI Code Generation

copy

Full Screen

1import UIKit2class ViewController: UIViewController {3    override func viewDidLoad() {4        super.viewDidLoad()5    }6    override func viewWillAppear(_ animated: Bool) {7        super.viewWillAppear(animated)8        print("View Will Appear")9    }10}11import UIKit12class ViewController: UIViewController {13    override func viewDidLoad() {14        super.viewDidLoad()15        print("View Did Load")16    }17    override func viewWillAppear(_ animated: Bool) {18        super.viewWillAppear(animated)19        print("View Will Appear")20    }21}22import UIKit23class ViewController: UIViewController {24    override func viewDidLoad() {25        super.viewDidLoad()26        print("View Did Load")27    }28    override func viewWillAppear(_ animated: Bool) {29        super.viewWillAppear(animated)30        print("View Will Appear")31    }32    override func viewDidAppear(_ animated: Bool) {33        super.viewDidAppear(animated)34        print("View Did Appear")35    }36}37import UIKit38class ViewController: UIViewController {39    override func viewDidLoad() {40        super.viewDidLoad()41        print("View Did Load")42    }43    override func viewWillAppear(_ animated: Bool) {44        super.viewWillAppear(animated)45        print("View Will Appear")46    }47    override func viewDidAppear(_ animated: Bool) {48        super.viewDidAppear(animated)49        print("View Did Appear")50    }51    override func viewWillDisappear(_ animated: Bool) {52        super.viewWillDisappear(animated)53        print("View Will Disappear")54    }55}56import UIKit57class ViewController: UIViewController {58    override func viewDidLoad() {59        super.viewDidLoad()60        print("View Did Load")61    }62    override func viewWillAppear(_ animated: Bool) {63        super.viewWillAppear(animated)64        print("View Will Appear")65    }66    override func viewDidAppear(_ animated: Bool) {67        super.viewDidAppear(animated)68        print("View Did Appear")69    }

Full Screen

Full Screen

viewWillAppear

Using AI Code Generation

copy

Full Screen

1import UIKit2class ViewController: UIViewController {3override func viewDidLoad() {4    super.viewDidLoad()5}6override func viewWillAppear(_ animated: Bool) {7    super.viewWillAppear(animated)8    print("viewWillAppear is called")9}10override func viewDidAppear(_ animated: Bool) {11    super.viewDidAppear(animated)12    print("viewDidAppear is called")13}14override func viewWillDisappear(_ animated: Bool) {15    super.viewWillDisappear(animated)16    print("viewWillDisappear is called")17}18override func viewDidDisappear(_ animated: Bool) {19    super.viewDidDisappear(animated)20    print("viewDidDisappear is called")21}22}23import UIKit24class ViewController: UIViewController {25override func viewDidLoad() {26    super.viewDidLoad()27}28override func viewWillAppear(_ animated: Bool) {29    super.viewWillAppear(animated)30    print("viewWillAppear is called")31}32override func viewDidAppear(_ animated: Bool) {33    super.viewDidAppear(animated)34    print("viewDidAppear is called")35}36override func viewWillDisappear(_ animated: Bool) {37    super.viewWillDisappear(animated)38    print("viewWillDisappear is called")39}40override func viewDidDisappear(_ animated: Bool) {41    super.viewDidDisappear(animated)42    print("viewDidDisappear is called")43}44}45import UIKit46class ViewController: UIViewController {47override func viewDidLoad() {48    super.viewDidLoad()49}50override func viewWillAppear(_ animated: Bool) {51    super.viewWillAppear(animated)52    print("viewWillAppear is called")53}54override func viewDidAppear(_ animated: Bool) {55    super.viewDidAppear(animated)56    print("viewDidAppear is called")57}58override func viewWillDisappear(_ animated: Bool) {59    super.viewWillDisappear(animated)60    print("viewWillDisappear is called")61}62override func viewDidDisappear(_ animated: Bool) {63    super.viewDidDisappear(animated)64    print("viewDidDisappear is called")65}66}67import UIKit68class ViewController: UIViewController {69override func viewDidLoad() {70    super.viewDidLoad()71}72override func viewWillAppear(_ animated: Bool) {73    super.viewWillAppear(animated)74    print("

Full Screen

Full Screen

viewWillAppear

Using AI Code Generation

copy

Full Screen

1import UIKit2class ViewController: UIViewController {3    override func viewDidLoad() {4        super.viewDidLoad()5    }6    override func viewWillAppear(_ animated: Bool) {7        print("viewWillAppear")8    }9}10import UIKit11class ViewController: UIViewController {12    override func viewDidLoad() {13        super.viewDidLoad()14    }15    override func viewWillDisappear(_ animated: Bool) {16        print("viewWillDisappear")17    }18}19import UIKit20class ViewController: UIViewController {21    override func viewDidLoad() {22        super.viewDidLoad()23    }24    override func viewDidAppear(_ animated: Bool) {25        print("viewDidAppear")26    }27}28import UIKit29class ViewController: UIViewController {30    override func viewDidLoad() {31        super.viewDidLoad()32    }33    override func viewDidDisappear(_ animated: Bool) {34        print("viewDidDisappear")35    }36}37import UIKit38class ViewController: UIViewController {39    override func viewDidLoad() {40        super.viewDidLoad()41    }42    override func viewWillLayoutSubviews() {43        print("viewWillLayoutSubviews")44    }45}46import UIKit47class ViewController: UIViewController {48    override func viewDidLoad() {49        super.viewDidLoad()50    }51    override func viewDidLayoutSubviews() {52        print("viewDidLayoutSubviews")53    }54}55import UIKit56class ViewController: UIViewController {57    override func viewDidLoad() {58        super.viewDidLoad()59    }60    override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {61        print("viewWillTransition")62    }63}

Full Screen

Full Screen

viewWillAppear

Using AI Code Generation

copy

Full Screen

1override func viewWillAppear(_ animated: Bool) {2    super.viewWillAppear(animated)3    print("viewWillAppear")4}5override func viewDidAppear(_ animated: Bool) {6    super.viewDidAppear(animated)7    print("viewDidAppear")8}9override func viewWillDisappear(_ animated: Bool) {10    super.viewWillDisappear(animated)11    print("viewWillDisappear")12}13override func viewDidDisappear(_ animated: Bool) {14    super.viewDidDisappear(animated)15    print("viewDidDisappear")16}17override func viewDidLoad() {18    super.viewDidLoad()19    print("viewDidLoad")20}21override func didReceiveMemoryWarning() {22    super.didReceiveMemoryWarning()23    print("didReceiveMemoryWarning")24}25override func loadView() {26    super.loadView()27    print("loadView")28}29override func viewWillLayoutSubviews() {30    super.viewWillLayoutSubviews()31    print("viewWillLayoutSubviews")32}33override func viewDidLayoutSubviews() {34    super.viewDidLayoutSubviews()35    print("viewDidLayoutSubviews")36}37override func viewDidLoad() {38    super.viewDidLoad()39    print("viewDidLoad")40}41override func viewWillAppear(_ animated: Bool) {42    super.viewWillAppear(animated)43    print("viewWillAppear")44}

Full Screen

Full Screen

viewWillAppear

Using AI Code Generation

copy

Full Screen

1override func viewWillAppear(_ animated: Bool) {2    super.viewWillAppear(animated)3}4override func viewDidLoad() {5    super.viewDidLoad()6}7override func viewDidAppear(_ animated: Bool) {8    super.viewDidAppear(animated)9}10override func viewWillDisappear(_ animated: Bool) {11    super.viewWillDisappear(animated)12}13override func viewDidDisappear(_ animated: Bool) {14    super.viewDidDisappear(animated)15}16override func viewWillLayoutSubviews() {17    super.viewWillLayoutSubviews()18}19override func viewDidLayoutSubviews() {20    super.viewDidLayoutSubviews()21}22override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {23    super.viewWillTransition(to: size, with: coordinator)24}25override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {26    super.viewWillTransition(to: size, with: coordinator)27}28override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {29    super.viewWillTransition(to: size, with: coordinator)30}31override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {32    super.viewWillTransition(to: size, with: coordinator)33}34override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {35    super.viewWillTransition(to: size, with: coordinator)36}

Full Screen

Full Screen

viewWillAppear

Using AI Code Generation

copy

Full Screen

1override func viewWillAppear(_ animated: Bool) {2    super.viewWillAppear(animated)3}4override func viewWillAppear(_ animated: Bool) {5    super.viewWillAppear(animated)6}7override func viewWillAppear(_ animated: Bool) {8    super.viewWillAppear(animated)9}10override func viewWillAppear(_ animated: Bool) {11    super.viewWillAppear(animated)12}13override func viewWillAppear(_ animated: Bool) {14    super.viewWillAppear(animated)15}16override func viewWillAppear(_ animated: Bool) {17    super.viewWillAppear(animated)18}19override func viewWillAppear(_ animated: Bool) {20    super.viewWillAppear(animated)21}22override func viewWillAppear(_ animated: Bool) {23    super.viewWillAppear(animated)24}25override func viewWillAppear(_ animated: Bool) {26    super.viewWillAppear(animated)27}28override func viewWillAppear(_ animated: Bool) {29    super.viewWillAppear(animated)30}31override func viewWillAppear(_ animated: Bool) {32    super.viewWillAppear(animated)33}34override func viewWillAppear(_ animated: Bool) {35    super.viewWillAppear(animated)

Full Screen

Full Screen

viewWillAppear

Using AI Code Generation

copy

Full Screen

1override func viewWillAppear(_ animated: Bool) {2    super.viewWillAppear(animated)3    print("viewWillAppear")4}5override func viewDidAppear(_ animated: Bool) {6    super.viewDidAppear(animated)7    print("viewDidAppear")8}9override func viewDidLoad() {10    super.viewDidLoad()11    print("viewDidLoad")12}13override func viewWillDisappear(_ animated: Bool) {14    super.viewWillDisappear(animated)15    print("viewWillDisappear")16}17override func viewDidDisappear(_ animated: Bool) {18    super.viewDidDisappear(animated)19    print("viewDidDisappear")20}

Full Screen

Full Screen

viewWillAppear

Using AI Code Generation

copy

Full Screen

1override func viewWillAppear(animated: Bool) {2        super.viewWillAppear(animated)3        if let index = self.tableView.indexPathForSelectedRow() {4            self.tableView.deselectRowAtIndexPath(index, animated: true)5        }6    }7override func viewDidAppear(animated: Bool) {8        super.viewDidAppear(animated)9        if let index = self.tableView.indexPathForSelectedRow() {10            self.tableView.deselectRowAtIndexPath(index, animated: true)11        }12    }13override func viewWillDisappear(animated: Bool) {14        super.viewWillDisappear(animated)15        if let index = self.tableView.indexPathForSelectedRow() {16            self.tableView.deselectRowAtIndexPath(index, animated: true)17        }18    }19override func viewDidDisappear(animated: Bool) {20        super.viewDidDisappear(animated)21        if let index = self.tableView.indexPathForSelectedRow() {22            self.tableView.deselectRowAtIndexPath(index, animated: true)23        }24    }25override func viewWillLayoutSubviews() {26        super.viewWillLayoutSubviews()27        if let index = self.tableView.indexPathForSelectedRow() {28            self.tableView.deselectRowAtIndexPath(index, animated: true)29        }30    }31override func viewDidLayoutSubviews() {32        super.viewDidLayoutSubviews()33        if let index = self.tableView.indexPathForSelectedRow() {34            self.tableView.deselectRowAtIndexPath(index, animated: true)35        }36    }37override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {38        super.willRotateToInterfaceOrientation(toInterfaceOrientation, duration: duration)39        if let index = self.tableView.indexPathForSelectedRow() {40            self.tableView.deselectRowAtIndexPath(index, animated: true)41        }42    }43override func willAnimateRotationToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {44        super.willAnimateRotationToInterfaceOrientation(toInterfaceOrientation

Full Screen

Full Screen

viewWillAppear

Using AI Code Generation

copy

Full Screen

1override func viewWillAppear(_ animated: Bool) {2    super.viewWillAppear(animated)3}4override func viewWillDisappear(_ animated: Bool) {5    super.viewWillDisappear(animated)6}

Full Screen

Full Screen

viewWillAppear

Using AI Code Generation

copy

Full Screen

1override func viewWillAppear(_ animated: Bool) {2    super.viewWillAppear(animated)3    let currentDate = Date()4    dateTextField.text = "\(currentDate)"5}6override func viewDidAppear(_ animated: Bool) {7    super.viewDidAppear(animated)8    let currentDate = Date()9    dateTextField.text = "\(currentDate)"10}11override func viewDidLoad() {12    super.viewDidLoad()13    let currentDate = Date()14    dateTextField.text = "\(currentDate)"15}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Swift-snapshot-testing automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful