Objective-C: What is .m?

John C. Bland II

This was a bit odd for me but I just got the answer I wanted.

When you create a class you create a .h (where applicable) and a .m. The .h is your interface. No sweat…seen these before. Hrmm…what does the “m” stand for though?

.m = implementation file

That makes sense. I mean I knew it was the @implementation code but I didn’t know what the “m” in the filename stood for.

Nothing mind-blowing…just blogging a note. ;-)




6 Responses to “Objective-C: What is .m?”

  • bbum Says:

    Or you can think of it terms of object oriented encapsulation.

    The .h file contains the public facing interface for your class; all the stuff that you expect folks using your code to see and understand.

    The .m file contains all the implementation details of your class; all the stuff that you might change at a whim as long as it doesn’t change the meaning of something in the .h.

    .m files can contain more than @implementations, they can contain private interfaces, too. And on the iPhone or 64 bit Mac OS X runtimes, they can implement private instance variables through class extensions and @synthesize.

  • John C. Bland II Says:

    @bbum
    Good stuff. Thanks for providing more clarity.

    I have a blog post coming up about @synthesize. It is interesting and I want to learn more about it.

  • FredJouldd Says:

    Thanks, good article.

  • Jimmy V Says:

    It is 2009 and you are just now writing about objective C? Where have you been for the past several years.

Leave a Reply

  • Get Adobe Flash playerPlugin by wpburn.com wordpress themes