开发者

Dealing with Objective-C #import dependencies

I'm creating a set of files (a library, basically) to accomplish a task which I will use in an iOS app. The library has one public header file that imports all the other header files so that code that uses this library only needs to import the one header. However, that public header also defines an enum that is u开发者_C百科sed internally by most of the other files, so those files need to import the public header. This creates circular dependencies, and I'm getting build errors relating to symbols not being recognized.

What is the right way to handle #imports in a situation like this, where a public header file makes a set of library objects available to the public, but the dependent files also need an enum (plus a protocol, actually) defined in the public header?


Extract the type definitions into a different header.

Otherwise, you'll have to use include guards — but that would really just be hacking around a design flaw.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜