Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top