Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Woodshark69

macrumors newbie
Original poster
Dec 12, 2012
6
0
As you can probably guess i am a beginner and am trying to figure out when I am suppose to use view.h and view.m. Recently I have purchased a 1 month trial of TeamTreehouse and am trying to make an app ilk bike race or hill climb racing. I am not going to be plagiarizing any information from these apps but it would be extremely helpful if you guys would use examples from these apps or other apps to help me find out when to use view.h and view.m. Thanks in advance!!
 
I would suggest you step away from the real coding for now and spend some time learning the fundamentals of Objective-C programming.
 
As you can probably guess i am a beginner and am trying to figure out when I am suppose to use view.h and view.m. Recently I have purchased a 1 month trial of TeamTreehouse and am trying to make an app ilk bike race or hill climb racing. I am not going to be plagiarizing any information from these apps but it would be extremely helpful if you guys would use examples from these apps or other apps to help me find out when to use view.h and view.m. Thanks in advance!!

I agree with Dejo. If you don't know the difference between a .h file and a .m file, you're no ready to start tackling developing a full featured game. You need to learn the basics first. What you are trying to do is like rebuilding a car engine without ever having held a screwdriver or a wrench.
 
If you don't know the difference between a .h file and a .m file it suggests you have no or minimal experience in C. Knowing C is a prereq to learning Obj-C. I suggest you read Learn C The Hard Way, it's a free online ebook.
 
As you can probably guess i am a beginner and am trying to figure out when I am suppose to use view.h and view.m. Recently I have purchased a 1 month trial of TeamTreehouse and am trying to make an app ilk bike race or hill climb racing. I am not going to be plagiarizing any information from these apps but it would be extremely helpful if you guys would use examples from these apps or other apps to help me find out when to use view.h and view.m. Thanks in advance!!

To answer your question:

C and Objective-C files come in pairs: A header (.h) file and an implementation (.m for Objective-C) file. I'll focus on Objective C.

Usually a .h and .m file declare the interface and implementation for a single class, although sometimes there can be more than one class defined in a .h/.m pair. There are also some specialized uses of header files that don't have a matching .m file. (defining protocols, constants, types, interfaces to Apple frameworks or third party libraries that only provide object code but no source code, etc.)

The header files serves several purposes. It declares the public interface that other files use to know what methods and functions there are in the .m file.

The .h file also defines the instance variables and properties that will be used in the .m file.

The .m file contains the code for the classes that are declared in the .h file.

There are other more advanced uses of these files like protocols and categories that I'm not going to describe here.
 
I would listen to these guys above.

But to let you know how I dealt with that when I was learning, and kinda grasped it. For me I saw it like a restaurant. The waiter hands you a menu or the .h file. On that menu you have things that you can order. The menu might say something like Chicken Pot Pie. What the menu does not tell you is how to make it like 1/2 cup chicken stock, 2 tsp salt and so on.

Now the .m is like the kitchen. You order the meal from the .h and the kitchen does the work. The chef gets a message to make the dish and here is where all the instructions are to create it that are not on the menu it's self. For each item on the menu, there is a method in the kitchen to create what you asked for.

There are more parts to a .h then that but that is the part that I hung up on the most. Again this is how I looked at it and it helped me understand it a little better.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.