Search code examples
iosxcodeswiftviewdidloadviewdidappear

Swift - ViewDidAppear called from another class


I have a simple application with two views. When I launch to the home view the viewDidLoad and viewDidAppear are called. When I go to another view in my application it calls super.viewDidLoad and calls the func, but it also calls viewDidAppear from the home view. I can't find any commands to call it (Searched entire code base). What could be causing this extra call?

* ADDITIONAL TESTS *

I added break points to find the issue.

1) home calls: viewdidLoad, then viewdidappear

2) click link to detailview

3) this calls deatailview viewdidload which calls super (aka home) view did load

4) home view did load finishes and then home viewdidappear is called

5) error in home viewdidappear

Any ideas why home viewdidappear was called afterwards?


Solution

  • As you mentioned, 'home' is the super class of your 'detail' view controller " deatailview super (aka home) ". You either haven't implemented the viewDidAppear or called super.viewDidAppear in the 'detail' vc , hence the superclass' (home vc's) viewDidAppear is executed.