We already know the cause and the solution: MyViewController.h imports MySubview.h, and MySubview.h imports MyViewController.h. The standard C header preprocessor trick does not help in this situation, and neither does import.

The solution is to use a forward declaration. For ObjC classes this looks like "@class Foo;". For functions it's a prototype delcaration: "int foo();". Structs are similar: "struct foo;", and C++ classes follow suit: "class Foo;".

In short, this is a well-known consequence of C requiring types to be defined before they're used.

--Kyle Sluder

On Sep 13, 2009, at 3:56 PM, Jay Reynolds Freeman <jay_reynolds_free...@mac.com > wrote:

Unfortunately, "#import" seems not to be working in the case given; I don't know why. The mechanism I suggested might be useful for chasing down why.

--  Jay Reynolds Freeman
---------------------
jay_reynolds_free...@mac.com
http://web.mac.com/jay_reynolds_freeman (personal web site)


On Sep 13, 2009, at 3:41 PM, Kyle Sluder wrote:

This does not solve the problem at hand (two interfaces need a declaration of each other's symbols). The mechanism you describe is obsoleted by #import.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to