Objective-C #import a whole directory
Hey guys, sure hope you can help me.
I've got around 50 Model-Classes stored in a seperate Folder (not only a gro开发者_运维百科up) and I really don't want to write an #import for each of these classes.
Is there a way to import a whole directory?
I know it's possible within other programming languaged and perhabs I simply used wrong syntax.
Plz help me! greets Infinite
#import
is just a variant of #include
. They don't allow to specify a whole directory.
You will have to specify each of your 50 header files.
You can generate that list with bash:
cd myfolder ; printf '#import "%s"\n' *.h > ../myheader.h
As a possible workaround you can import all of them in separate header(e.g. MyImports.h) and import only it whenever you need.
精彩评论