Skip to content

Instantly share code, notes, and snippets.

@asmallteapot
Created August 21, 2012 20:58
Show Gist options
  • Save asmallteapot/3419363 to your computer and use it in GitHub Desktop.
Save asmallteapot/3419363 to your computer and use it in GitHub Desktop.
Objective-C with Teapot Characteristics

(This is a first draft)

Some notes

  • I strongly prefer hard tabs, and set my editor to render them four columns wide.
    • I do, however, understand the rationale behind using four-wide soft tabs, and will expand on this in a later draft.
  • BSD Kernel Normal Form is the one true indentation style.

Object literals

// Number literals should only be boxed when backwards compatibility requires them.
NSNumber *one = @(1);
NSNumber *two = @(2);
NSNumber *three = @(3);

// Single-line array literals should have a space inside each bracket and no terminating comma.
NSArray *anArray = @[ one, two, three ];

// Multi-line literals should use a terminating comma and no spaces.
NSArray *anotherArray = @[
	one,
	two,
	three,
];

// Dictionary literals look the same, but with a space between the keys and values
NSDictionary *aDictionary = @{ @"foo": one, @"bar": two, @"baz": three };
NSDictionary *anotherDictionary = @{
	@"foo": one,
	@"bar": two,
	@"baz": three,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment