开发者

Objective-C #import a whole directory

开发者 https://www.devze.com 2022-12-16 19:35 出处:网络
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 cla

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消