Apple provides an Macro. This increases most notably the auto completion.
typedef NS_ENUM(NSInteger, UITableViewCellStyle) {
UITableViewCellStyleDefault = 0,
UITableViewCellStyleValue1,
UITableViewCellStyleValue2,
UITableViewCellStyleSubtitle
};
for distinct values.
if you want bitmasking for options, where several can go together, use NS_OPTIONS
typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
UIViewAutoresizingFlexibleRightMargin = 1 << 2,
UIViewAutoresizingFlexibleTopMargin = 1 << 3,
UIViewAutoresizingFlexibleHeight = 1 << 4,
UIViewAutoresizingFlexibleBottomMargin = 1 << 5
};
Usage as a bitmask
UIViewAutoresizing resizing = (UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin)
If you want to be able to set it from outside the class, add it to the header file
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSUInteger, InsetCellAlignment){
InsetCellAlignmentLeft,
InsetCellAlignmentRight
};
@interface InsetCell : UITableViewCell
@property InsetCellAlignment alignment;
@property(nonatomic)CGFloat inset;
@end
If you need to extend UIButton with some state it is a strong indication, that you are not using MVC correctly. A controller should be aware of the state and configure the button respectively.
That said you might be able to get your desired result using "Associative References" which can be used to simulate added member variables. IMO they are smelly and I never used them.
A category used along with associative references