• 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: confused about framework headers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: confused about framework headers


  • Subject: Re: confused about framework headers
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Fri, 22 Oct 2004 03:56:13 +0200

At 21:34 Uhr -0400 21.10.2004, Agent M wrote:
What do the header "roles" in a target actually do? I see that setting it to public puts the header into the exposed/ available framework headers.

Yes, that's what it's for. It lets you specify the "public" headers that will be included with the framework to let programmers use it.

I'd like to expose the API with one header but that header imports headers in the project which aren't "public" so it can't find them. Does this mean I'm supposed to make all the headers public? Or am I supposed to be using class profusely to avoid the inter-project imports?

You mean @class? Yes, that's one tool at your disposal to get around this issue. Another is to define a protocol and only let your users know about that protocol. Your class would implement the protocol, and you'd add a method to return "an NSObject subclass conforming to that protocol". Of course, this will not work for classes that you intend to be subclassed by your users, or to be instantiated via IB.

To allow instantiating via IB, you could of course define a "class cluster consisting of one class": People would just specify the cluster, whose init method would release the instance of itself and return an object of your internal class instead (which is basically how class clusters like NSArray are implemented in ObjC).

If you want them to subclass your class, you'll of course have to watch out for the "fragile base class problem" because you can't just add instance variables without disturbing the memory layout expected by subclasses. So, if you expect subclasses, you'll have to write a very clean header file instead.

Of course, often you can achieve the same flexibility you get from subclassing by allowing for delegation in your class. That may be a nice compromise between a clean, safe protocol as a public API, and a very customizable class for your framework's clients.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >confused about framework headers (From: Agent M <email@hidden>)

  • Prev by Date: Re: Fast direct pixel access
  • Next by Date: Re: Bug in NSArrayController? (immutable instead of mutable dictionaries)
  • Previous by thread: confused about framework headers
  • Next by thread: how to force NSSavePanel not to display 'Replace' dialog?
  • Index(es):
    • Date
    • Thread