I am new to iOS programming. I see that there are functions defined in my view controller such as
- (void) viewDidLoad
How is viewDidLoad an instance method as denoted by the hyphen? I don’t think I ever instantiate this class.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you create a *.xib file (the view) in Xcode and set its class (the controller) in the identity inspector, an instance of that class is instantiated when you load the *.xib file via
And
viewDidLoadis called automatically once the *.xib file has fully loaded.You can see this by simply creating a new Single View iOS project in Xcode. In AppDelegate.m you’ll see a line similar to the one above in the
-(BOOL) application: didFinishLaunchingWithOptions:method. In the ViewController.xib file, if you click on “File’s Owner” and show the Identity Inspector, you’ll see that the classViewControlleris the one “linked” with the *.xib.