سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top