Note that there are some explanatory texts on larger screens.

plurals
  1. POCyclic Reference - protocols and subclasses
    text
    copied!<p>I'm getting some cyclic reference (I think) problems between a few classes that require imported headers due to either subclassing or protocol definitions. I can explain why things are set up this way but I'm not sure it's essential. Basically these classes are managing reciprocal to-many data relationships.</p> <p>The layout is this:<br> Class A imports Class B because it's a delegate of Class B and needs its protocol definition.<br> Class B imports Class C because it's a subclass of Class C.<br> Class C imports Class A because it's a delegate of Class A and needs its protocol definition. </p> <p>Here's some sample code that illustrates the problem. The errors I'm getting are as follows: In Class A - "Can't find protocol definition for Class_B_Delegate". In Class B - "Can't find interface declaration for Class C - superclass of Class B." In Class C - "Can't find protocol definition for Class_A_Delegate".</p> <p>Class A header:</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import "Class_B.h" @protocol Class_A_Delegate @end @interface Class_A : NSObject &lt;Class_B_Delegate&gt; { } @end </code></pre> <p>Class B header:</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import "Class_C.h" @protocol Class_B_Delegate &lt;NSObject&gt; @end @interface Class_B : Class_C { } @end </code></pre> <p>Class C Header:</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import "Class_A.h" @interface Class_C : NSObject &lt;Class_A_Delegate&gt; { } @end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload