Skip to content

Instantly share code, notes, and snippets.

@gose
Created May 31, 2012 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gose/2843730 to your computer and use it in GitHub Desktop.
Save gose/2843730 to your computer and use it in GitHub Desktop.
//
// MyViewController.m
//
#import <QuartzCore/QuartzCore.h>
#import "MyViewController.h"
#import "MBProgressHUD.h"
#import "Query.h"
#import "QueryResponse.h"
@interface MyViewController ()
{
MBProgressHUD *hud;
}
- (QueryResponse *)queryServiceWithQuery:(Query *)query;
@end
@implementation MyViewController
@pragma mark - Accessor methods
@synthesize *resultsTable;
@pragma mark - Parent methods
- (void)viewDidLoad
{
[super viewDidLoad];
hud = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:hud];
}
@pragma mark - Public methods
- (IBAction)reload:(id)sender
{
// reload:
}
@pragma mark - Private methods
- (QueryResponse *)queryServiceWithQuery:(Query *)query
{
// queryServiceWithQuery:
}
@pragma mark - UITableViewDataSource methods
...
@pragma mark - UITableViewDelegate methods
...
@end
@gose
Copy link
Author

gose commented May 31, 2012

Here's my best practice for organizing obj-c classes; particularly, the #pragma mark directives. They are quite useful for calling up the "Show Document Items" keyboard shortcut and knowing generally where to look for a method. That shortcut is mapped to ctrl-6 by default, but I have it remapped to ctrl-d for convenience.

  • Alphabetized global #imports
  • #import interface
  • Alphabetized local #imports
  • Class extension
  • Implementation
    • Accessor methods
    • Parent methods
    • Public methods
    • Private methods
    • Delegate methods

For the delegate methods, I use their formal name so option-clicking them pulls up their documentation.

Do you have a better or different way? Let me know!

@gose
Copy link
Author

gose commented May 31, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment