You can use #pragma mark
to separate sections. Xcode will show these values when you drop down the list of symbols in the file.
Example:
#pragma mark Constructors
You even do:
#pragma mark -
to show a line in the symbol drop down list.
Question
In my intro to programming courses, most things were split up into sections with comments, like this:
@interface ClassA : NSObject
{
@protected
NSMutableArray *_objects
}
/* constructors */
+(id) initWithObjects: (NSMutableArray *) objects;
-(id) initWithObjects: (NSMutableArray *) objects;
/* properties */
@property(nonatomic, strong) NSMutableArray *objects;
/* methods */
- (void) haveFunWithObjects;
I find this to be a useful way of organizing things, but often times, I'll need to preface or insert documentation in the middle of a rather esoteric section of code with a brief description, and then I get confused as to how I should be documenting it:
@interface NDTuple : NSObject
{
@protected
NSMutableArray *_components;
NSUInteger _dim;
}
/* constructors */
/* This constructor initializes the components array to elements all of 0 */
+(id) initToZeroForDim: (NSUInteger) dim;
-(id) initToZeroForDim: (NSUInteger) dim;
+(id) initWithComponents: (NSMutableArray *)components;
-(id) initWithComponents: (NSMutableArray *)components;
/* properties */
@property(nonatomic, strong) NSMutableArray *components;
@property(nonatomic, assign) NSUInteger dim;
/* methods */
- (NDTuple *) minus: (NDTuple *) subTuple;
- (void) replaceComponentAtIndex: (NSUInteger) index withComponent:(id)anObject;
- (id) componentAtIndex:(NSUInteger) index;
Maybe this wasn't the best example, but what I'm really asking is if there is a better way to split up code into its common sections?
Solution
You can use #pragma mark
to separate sections. Xcode will show these values when you drop down the list of symbols in the file.
Example:
#pragma mark Constructors
You even do:
#pragma mark -
to show a line in the symbol drop down list.