Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

How Xcode calls methods in view controller class when we are running the project?

I know we can write our code in the view did load method so that after the view finishes loading, our codes inside of viewDidLoad method can be executed. My question is how does Xcode know to call viewDidLoad method when the project is running? are there any specific built in codes to make Xcode running the project? I know if we run want to run project, we can simply press run button to run, but I am kinda curious about what's going behind the scene. Please help! Appreciate it!

1 Answer

The viewDidLoad method is called as part of the "View Controller Lifecycle", which is a set of methods that you define that will be called automatically by iOS at key points in the life of your view controller. Other methods include viewWillAppear:, viewDidAppear:, viewWillDisappear:, viewDidDisappear:, and didRecieveMemoryWarning. These are all called automatically by iOS at certain important times during the life of your view controller

Thanks!!