Question

Can't I leave out #import "foo.h" in .m file if it's already in the prefix header?

The product still builds successfully when I leave it out. But, I've noticed that the Xcode templates keep them in. Why?

Is the answer the same for #include?

Was it helpful?

Solution

I don't know why it does this, but it doesn't hurt because #import protects from double #include by checking if something is already #import-ed or #include-d, so no, the same scenario wouldn't work with #include.

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