Tag Archives: Swift error

[Solved]Swift error: Method does not override any method from its superclass

problem reason: wrong method name

Viewcontroller lifecycle

 1 // This method is called when the view is loaded
 2 override func loadView() {
 3 super.loadView()
 4 print("Loading the view")
 5 }
 6     
 7 // Call this method when the loaded view is finished
 8 override func viewDidLoad() {
 9 super.viewDidLoad()
10 print("End of loading view")
11 }
12     
13 // Call this method when the view is about to be displayed
14 override func viewWillAppear(_ animated: Bool) {
15 super.viewWillAppear(animated)
16 print("The view is about to be displayed")
17 }
18     
19 // Call this method when the view is already displayed
20 override func viewDidAppear(_ animated: Bool) {
21 super.viewDidAppear(animated)
22 print("The view has been displayed")
23 }
24     
25 // Call this method when the view is about to disappear
26 override func viewWillDisappear(_ animated: Bool) {
27 super.viewWillDisappear(animated)
28 print("The view is about to disappear")
29 }
30     
31 // Call this method when the view has disappeared
32 override func viewDidDisappear(_ animated: Bool) {
33 super.viewWillDisappear(animated)
34 print("The view has disappeared")
35 }
36 
37 // This method is executed when a memory warning is received
38     override func didReceiveMemoryWarning() {
39         super.didReceiveMemoryWarning()
40     }