0

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?

ma11hew28
  • 121,420
  • 116
  • 450
  • 651
  • 1
    possible duplicate of [Why do Xcode templates have #imports that duplicate Prefix.pch?](http://stackoverflow.com/questions/6462288/why-do-xcode-templates-have-imports-that-duplicate-prefix-pch) – Yuji Aug 11 '11 at 13:35

1 Answers1

1

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.

Filip Radelic
  • 26,607
  • 8
  • 71
  • 97