Re: private methods and variables
Re: private methods and variables
- Subject: Re: private methods and variables
- From: Ken Thomases <email@hidden>
- Date: Tue, 29 Jul 2008 18:19:37 -0500
On Jul 29, 2008, at 4:02 PM, Torsten Curdt wrote:
This question is NOT about private APIs from Apple but more about
how to organize structure my own code.
Especially for a framework I don't want to expose implementation
details to the interface.
So while I found the suggestion to use a special category like:
@interface MyClass
-(void) publicMethod;
@end
@interface MyClass (Private)
{
int privateVariable;
This is an instance variable. There's one per instance.
}
-(void) privateMethod;
@end
I am not sure why that would be better than to just do
@interface MyClass
-(void) publicMethod;
@end
@implementation MyClass
int privateVariable;
There is only one of these across the entire program. It's not an
instance variable. It's as close as Objective-C gets to what would be
a "class variable" in another language. (Although it should probably
be declared "static" to limit its linkage to this translation unit.)
-(void) privateMethod {
}
-(void) publicMethod {
}
@end
Cheers,
Ken
_______________________________________________
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