Re: Exposing Methods in a Framework
Re: Exposing Methods in a Framework
- Subject: Re: Exposing Methods in a Framework
- From: Ryan Britton <email@hidden>
- Date: Wed, 31 May 2006 12:52:24 -0700
You can have as many header and source files for one class as you
want. In Objective-C, these are accomplished using categories (see
http://nextstep.sdf-eu.org/clocFAQ/#categories). For classes with
few private methods, it's also not too unwieldy to put the private
interface declaration at the top of the source file.
In my frameworks, I typically have two headers and one source file.
The public header contains the class declaration, instance variables,
and public method declarations. The private header is declared as a
category to the class and contains the private method declarations.
The source file imports both of these and has two @implementation
sections, one for the public segment and one for the private segment.
Ryan
On May 31, 2006, at 12:34 PM, David Alter wrote:
I'm looking at the Apple Documentation on Dynamic Loading Code
<http://developer.apple.com/documentation/Cocoa/Conceptual/
LoadingCode/Tasks/UsingPlugins.html> In in they talk about having
public and private header files. Private header files are not
included as part of your framework.
Form the docs
"Once you have finished your base class, you should package the
compiled implementation with the header file in a framework for
plug-in developers to use. To build a framework, use Xcode’s Cocoa
Framework project template. Make sure you designate private and
public header files as you intend in the Build Phases > Headers
section of the Target Settings pane."
I have also fond a reference to this in one of the Books I have
("Cocoa Programming" by Angustish, Buck, and Yacktman).
Now this brings up the question of do I have two separate header
files for one object? One is representative of the public entry
points and one that has the private entry points. This is what the
book implies I should do. Can I have my interface definition in two
files? Is there special syntax needed for that?
thanks for the help
-dave
On May 31, 2006, at 4:56 AM, John C. Randolph wrote:
On May 31, 2006, at 2:21 AM, Håkan Waara wrote:
I would find it slightly cleaner by "hiding" your private ivars
inside a category of the class, that you define elsewhere. For
example:
This is what you have in your public header:
@interface ClassForEveryone : NSObject
{
}
...
@end
Then in a private header, you do:
@interface ClassForEveryone (Private)
{
id secretVar;
}
...
@end
Well, aside from not being legal Obj-C syntax, your example above
would have two different instance sizes for the same class.
The way that Apple's frameworks typically hide ivars today is to
just put a pointer with a name like "reserved" in storage
declaration, and then allocate their private storage in their -
init methods.
-jcr
John C. Randolph,
VP, Engineering
Stealth Imaging, Inc. <email@hidden>
_______________________________________________
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
_______________________________________________
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