Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Xcode autocompletion suggest .m files when importing?

Just wondering -

When you start to type #import "

Xcode suggests .m files and .h files. I just had a few hours of frustration after mistakenly importing .m file.

Is that a bad design? Can you import .m files?

like image 746
shannoga Avatar asked Jul 29 '14 14:07

shannoga


1 Answers

You can import any files. #import is just a preprocessor directive that basically says "include contents of the file I tell you into the current file". There are some include guards as well, but the import does just that - it imports the file you tell it to.

Importing the header with .h file is probably more of a convenience/convention (please don't beat me for this, I'm just guessing) unless there's some C/C++ standard that says otherwise.

like image 143
Eimantas Avatar answered Nov 19 '22 15:11

Eimantas