Objective-C: What is .m?

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. ;-)

  • http://www.friday.com/bbum/ bbum

    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.

  • http://www.johncblandii.com John C. Bland II

    @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

    Thanks, good article.

    • http://www.johncblandii.com John C. Bland II

      No sweat.

  • http://slickhack.com Jimmy V

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

    • http://www.johncblandii.com John C. Bland II

      I’ve been living in about 4 other languages comfortably. Objective-C had 0 appeal until recently. Heck…I just bought my first Mac in October 09. ;-)