Build a Simple iPhone App with Objective-C
Views and View Controllers
I don;t know why it is different from each other!
I highly recommend taking the pre-requisite to this course, Objective C Basics. It will REALLY help in understanding these videos and I think you are severely hurting yourself if you don't go through them.
.h is seen as a 'declaration' file, where .m is seen as an 'implementation' file.
When you drag the connect the button 'Show Another Fun Fact' over to Viewcontroller.m, it creates a method, showFunFact. At first, we had nothing in this method (ie, clicking the button would do nothing). We initially added NSLog, which would print a string of our choice to the console when clicked.
Now, this may not be the best explanation, but the label is dragged to .h because we are DECLARING the label here (as a property). It is of the class UILabel and is declared as a pointer (the asterisk) so we can reference it. To 'implement' this label with the button, we need to do this in the .m file: the implementation file. This is done in the showFunFact method:
self.funFactLabel.text = @"another interesting fact!";
The way I try to look at it is this:
.h files you can declare stuff, but if you want to do cool shit with these things, you have to implement them in the .m files. I see .m files as 'under the hood'.
Posting to the forum is only allowed for members with active accounts.
Please sign in or sign up to post.
I forgot my password