How @class helps resolve circular references in header files.

I just experienced my very first compile failure caused by circular references in Ojective-C header files. This is where Class X imports Class Y and Class Y imports Class X. John Muchow has a very nice explanation of how using the @class directive can resolve this.

Note that there also exists a @protocol directive which can be used in a similar way if you happen to create a circular reference when protocol A references protocol B and vice versa.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s