I have an Objective-C protocol:
typedef enum {
ViewStateNone
} ViewState;
@protocol ViewStateable
- (void)initViewState:(ViewState)viewState;
- (void)setViewState:(ViewState)viewState;
@end
I'm using this protocol in the following class:
#import "ViewStateable.h"
typedef enum {
ViewStateNone,
ViewStateSummary,
ViewStateContact,
ViewStateLocation
} ViewState;
@interface ViewController : UIViewController <ViewStateable> {
}
@end
I won't go too far into the specifics of my application, but what I'm doing here is typedef
ing an enumeration in a protocol so that the protocol's methods can take an input value of that type.
I'm then hoping to redeclare or extend that typedef in the classes that conform to that protocol, so that each class can have their own view states. However, I'm running into the following two errors:
Redeclaration of enumerator 'ViewStateNone'
Conflicting types for 'ViewState'
I'm ashamed to admit that my knowledge of C (namely typedef
s) is not extensive, so is what I'm trying to do here, firstly, possible and, secondly, sensible?
Cheers friends.