views:

26

answers:

2

I am making a plug-in system for my application. It uses a framework with a class called vertCon, which currently looks like this:

@interface vertCon : NSObject {
    NSProgressIndicator *progressBar;
}

/* May not be accessible by child classes */
@property (nonatomic, retain) IBOutlet NSProgressIndicator *progressBar;

/* These two are used by child classes and may not be overridden */
- (void)updateProgessIndicator; // <-- epic spelling fail
- (void)epicFailWithError:(NSError *)error;

@end

(there is one object of a child class of vertCon per progress bar)

How can I do this? Thanks.

A: 

You can put method signatures in your .m file in a private interface. In your case you might put this into vertCon.m:

@interface vertCon (PrivateMethods)
- (void)updateProgessIndicator; // <-- epic spelling fail
- (void)epicFailWithError:(NSError *)error;
@end
samkass
He wants his subclasses to be able to call those methods, just not override them, so it doesn't make much sense to declare them internally like that.
imaginaryboy
+1  A: 

You cannot prevent a subclass from overriding the methods. Also, having declared the progressBar property, you also cannot prevent access to your internal NSProgressIndicator reference.

You can prevent access to progressBar if you drop the declared property and declare the ivar as @privaate, as follows:

@interface vertCon : NSObject {
@private
    NSProgressIndicator *progressBar;
}
// etc, etc
@end

However I suspect given the IBOutlet declaration that you need the ivar exposed as a property at least to allow setting it up via a xib.

This really is a case where you just have to document the intention (that is, subclasses should make use of, but not override, your update and epicFail methods).

imaginaryboy