Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including multiple classes in the same header file

Tags:

objective-c

I have an idea on how to do this, but I want to make sure I do it right....

I have five data classes. When I use one I typically use all of them (but not always).

Each class has a separate header file. I am getting sick of linking in each header file separately.

What is the best way resolve this issue?

like image 488
Mel Avatar asked Jul 19 '26 06:07

Mel


1 Answers

Create a new header file called "DataFiles.h". Inside that, have your five #import statements. Then whenever you need the file classes, just #import "DataFiles.h".

Beware of circular dependencies.

(This is how Cocoa, Foundation, UIKit, CoreData, etc all behave. Notice that you just #import <Cocoa/Cocoa.h>, which imports everything else. Open up Cocoa.h and take a look)

like image 80
Dave DeLong Avatar answered Jul 22 '26 05:07

Dave DeLong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!