• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Circular references
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Circular references


  • Subject: Re: Circular references
  • From: Kyle Sluder <email@hidden>
  • Date: Sun, 13 Sep 2009 16:17:56 -0700

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 <email@hidden > 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
---------------------
email@hidden
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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Circular references
      • From: "Henry McGilton (Boulevardier)" <email@hidden>
References: 
 >Circular references (From: DKJ <email@hidden>)
 >Re: Circular references (From: Jay Reynolds Freeman <email@hidden>)
 >Re: Circular references (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Circular references
  • Next by Date: Re: Mac Mini or iMac for Cocoa Development?
  • Previous by thread: Re: Circular references
  • Next by thread: Re: Circular references
  • Index(es):
    • Date
    • Thread