循环依赖 [英] Cyclic dependencies
问题描述
我对Cyclic依赖感到困惑。我有两个.m文件,我需要在彼此中使用这两个文件。
I am confused about Cyclic dependencies. I have two .m file and I need used those two files in each other.
例如两个文件Ah / Am和Bh / .m现在我必须访问文件Ah / .m的变量为Bh / .m,文件Bh / .m的变量为Ah / .m我将Ah导入Bh和Bh导入Ah但是它给出了一个错误。
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 want to use Delegate file ! is there any way to do the same without Delegate file ?
谢谢..
推荐答案
您应该将#imports放在.m文件而不是.h
如果您在.h
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
这篇关于循环依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!