Thursday, March 6, 2014

Pragma Mark Scheme for iOS Dev


If you want to be like all the smart people you read about on the Internet, you'll keep your files really well-organized. If you have such long files that you need to use pragma marks (which some people, including Jeff Atwood, I recall, think means that your files are too long) you have a basic organizational problem. Now the solution to this is, of course, "bust the file up into sections and stick to those." But what would those sections be? So I'm usually going by functionality, but then I inevitably lose it and end up with no organization at all, or (worse) using it in half the file.

The reason that I failed is that I cannot use a scheme that requires you to know what each method does. That's very time-consuming and, in a sense, redundant with the messages you see passed in the code.

So here's my new scheme, which is very easy to use because it doesn't require you to think. I've been trying this for a while and it's great.

#pragma mark - class methods
#pragma mark - initializers, dealloc, and lifecycle methods
// like didMoveToSuperview
#pragma mark - property accessors
#pragma mark - public overrides
#pragma mark - public property accessor overrides
#pragma mark - public methods
#pragma mark - protocol A methods
#pragma mark - protocol B methods
#pragma mark - dependent-object lifecycle
// like viewDidLoad, viewDidAppear, etc., NOT like hideView
#pragma mark - Methods not in public interface
#pragma mark - Not Implemented

No comments: