开发者

Cyclic dependencies

I am confused about Cyclic dependencies. I have two .m file and I need used those two files in each other.

For example two files A.h/A.m and B.h/.m Now I have to access the variable of file A.h/.m into B.h/.m and the variable of file B.h/.m into A.h/.m I import A.h into B.h and B.h into A.h But it gives an error.

And ya I don't w开发者_StackOverflowant to use Delegate file ! is there any way to do the same without Delegate file ?

Thanks..


You should probably place the #imports in the .m file instead of the .h You may need to forward declare the classes if you reference them in the .h


From What is the difference between @class and #import

@class is used to avoid circular dependency... This prevents circular references where in one header A imports a second header B which(B) imports the first(A) which imports the second (B)and so on in an endless cycle....@class is generally used to ask compiler to look for its definition at runtime... especially when it resides in some static library..

Pls see this too

when and where to put @class declarations

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜