Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do Objective-C files use the .m extension?

People also ask

What is .m file in Objective-C?

An M file is a class implementation file used by programs written in Objective-C. It begins with the @implementation directive and initializes variables and functions that can be referenced by other Objective-C source files. M files may also reference header (.

What is .h and .m file in Objective-C?

h is called the Header file and the . m is called the Implementation file. Together, they form the AppDelegate class.

What is .m code file?

An m-file, or script file, is a simple text file where you can place MATLAB commands. When the file is run, MATLAB reads the commands and executes them exactly as it would if you had typed each command sequentially at the MATLAB prompt. All m-file names must end with the extension '. m' (e.g. test.

What is a .m file extension iOS?

Since M files are objective-c files, they are used for the implementation of Apple's Mac OS X and iOS operating system applications. There are many applications that can open M files and one of the most popular applications used is the Apple Xcode by which M files are considered part of its projects.


Today most people would refer to them as "method files", but

"The .m extension originally stood for "messages" when Objective-C was first introduced, referring to a central feature of Objective-C [...]"

(from the book "Learn Objective-C on the Mac" by Mark Dalrymple and Scott Knaster, page 9)

EDIT: To satisfy an itch I emailed Brad Cox, the inventor of Objective-C, about the question and he answered with this single line:

"Because .o and .c were taken. Simple as that."

Here's the email as visual proof:

Visual Proof


It stands for "methods". From the comp.lang.objective-C FAQ:

The organisation of Objective-C source is typically similar to that of C or C++ source code, with declarations and object interfaces going into header files named with a .h extension, and definitions and object implementations going in files named with a .m (short for methods) extension.


.m files contain the (m)ethods. Possible reason?