Alex Rivera | Logout

In Objective-C, importing same headers in every class make compile time longer?

Asked 2012-06-06T07:39:08.353
10

I'm a beginner of Objective-C/iOS programing.

I want make a one header file which includes all class headers I use in my project.
And import the header in every class header file.

Like this question:
Including multiple classes in the same header file

But does this approach increase compile time?
Or are there any other disadvantage?

Please tell me the good ways to import headers.

Edit
Report

2 Answers

7

The issue with all the classes in one header is that every time you change a class header then all the files including it even indirectly will need to be recompiled, whilst if you only import the needed class and also use @class when you can then only the files that directly use the class need to be recompiled. Thus in the first case there will be many more compilations than in the latter. This is the way I would recommend to start.

However when your code becomes more stable and classes do NOT change then putting them all in one header can improve the compile time as the precompiled header will contain the same information for each file. What I would do is when the code is not changing so much is put the mature classes into a Framework and the Framework header will include all these classes.

answered 2012-06-06T07:46:39.900
6

You can import that header file in your projects prefix_pch file.then You can use it in Your classes .

answered 2012-06-06T07:43:45.353

Your Answer