iOS Dev Nugget 9 #import as few header files in your header files as possible


Need to run a code review on your codebase? Hire me

import is a preprocessor mechanism in Objective C (as well as C and C++). When file A #import file B, B is basically copy and pasted into A and processed. When you have many unnecessary #import statements, building an app can take longer than it needs to.

Use @class statements to declare classes where possible in your header files (.h) and put #import statements in your implementation files (.m) instead.

This applies to #include too.

Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No


Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter


View archives of past issues