This question is not well written and I feel helpless.
Object-C is actually a language for embedding runtime-level Object calls in C or C ++ code!
What is a running-level object call, that is, an object call is not at the syntax level, but at the runtime level after compilation. Similar technologies include Microsoft's COM and open Object Organization's Corba, however, the last two do not add the calling content of the running-level object to the implementation language, but use separate IDL syntax and files!
After understanding the above, we can understand that the compiler should regard the source file as C or C ++ for compilation!
Method 1: directly change the extension
The. m file is to compile the source file as a C file written with Object-C.
The. mm file is to compile the source file as a C ++ file written with Object-C.
Method 2: Use Xcode to change the file attributes
Select a file and open Filey-> Get Info of Menu.
Change the drop-down selection of File Type. I believe the programmer can see at a glance what it means :)